-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Conversation
WalkthroughUpdated the expression transform to omit leading/trailing raw text slices when processing TypeScript AST nodes, and added a unit test verifying a template expression containing a TypeScript type assertion is preserved in generated code. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Parser
participant Transform as transformExpression
participant Builder as compoundChildren
Note over Parser: parse expression -> AST (may include TS nodes)
Parser->>Transform: provide AST node
alt AST node is TS_NODE_TYPES
Transform->>Builder: iterate identifiers (isTSNode=true)
Builder-->>Transform: push identifier tokens only (skip leading/trailing raw slices)
else AST node is non-TS
Transform->>Builder: iterate identifiers (isTSNode=false)
Builder-->>Transform: push leading raw slice, identifiers, trailing raw slice
end
Transform->>Transform: produce transformed expression node
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@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_TYPESto 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.snapis 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_TYPESis 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