-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
fix(compiler-core): remove types for expressions #13397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new test case was added to the compiler core's expression transform tests to verify correct handling of TypeScript type assertions in template expressions. Additionally, the transform logic was updated to exclude leading and trailing raw text slices around identifiers when the AST node type is one of the TypeScript node types. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts (1)
720-724
: Good test coverage for TypeScript type assertions.The test correctly validates that TypeScript type assertions are preserved in the generated code with proper parentheses wrapping. The assertion checks for the expected output and includes snapshot testing for regression prevention.
Consider adding test cases for other TypeScript node types from
TS_NODE_TYPES
to ensure comprehensive coverage:test('expression with various TypeScript types', () => { // Test TSNonNullExpression const { code: code1 } = compile(`<div @click="value!"></div>`) expect(code1).toMatch(`onClick: (_ctx.value!)`) // Test TSInstantiationExpression const { code: code2 } = compile(`<div @click="fn<string>"></div>`) expect(code2).toMatch(`onClick: (_ctx.fn<string>)`) // Test TSSatisfiesExpression const { code: code3 } = compile(`<div @click="obj satisfies Type"></div>`) expect(code3).toMatch(`onClick: (_ctx.obj satisfies Type)`) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap
is excluded by!**/*.snap
📒 Files selected for processing (2)
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts
(1 hunks)packages/compiler-core/src/transforms/transformExpression.ts
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/compiler-core/src/transforms/transformExpression.ts (1)
packages/compiler-core/src/babelUtils.ts (1)
TS_NODE_TYPES
(498-504)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
🔇 Additional comments (3)
packages/compiler-core/src/transforms/transformExpression.ts (3)
21-21
: LGTM! Import aligns with the TypeScript handling requirement.The import of
TS_NODE_TYPES
is correctly placed and necessary for the TypeScript expression wrapping logic.
351-352
: LGTM! Conditional wrapping logic is correctly implemented.The logic properly checks if the AST node type requires wrapping (TypeScript expressions) and conditionally adds the opening parenthesis before processing identifiers. This ensures TypeScript syntax like type assertions are preserved in the generated code.
382-382
: LGTM! Closing parenthesis correctly balances the opening one.The conditional closing parenthesis properly balances the opening parenthesis added earlier, ensuring well-formed expressions in the generated code.
similar to #13395
Summary by CodeRabbit
Bug Fixes
Tests