-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
fix(compiler): using guard instead of non-nullish assertion #13982
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
WalkthroughTightens v-bind shorthand processing in transformVBindShorthand by requiring a non-empty directive argument when handling same-name shorthand. The condition now checks both missing expression and presence of arg, and uses arg directly when present, aligning invalid-arg error reporting with existing logic. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Template Author
participant P as Parser
participant T as transformVBindShorthand
participant E as ErrorReporter
Dev->>P: Uses v-bind shorthand (e.g., :foo or :)
P->>T: Directive node (prop) with arg/exp
T->>T: Check: !prop.exp AND prop.arg
alt arg present and exp missing
T->>T: Treat as same-name shorthand using arg
else arg missing or invalid
T->>E: Report X_V_BIND_INVALID_SAME_NAME_ARGUMENT
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (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). (3)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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: |
Description
core/packages/compiler-core/src/transforms/transformVBindShorthand.ts
Line 20 in 079010a
This non-nullish assertion is harmful that it will be broken on language service when user has only typed
:
on an element, in that case we shouldn't treat the single:
as aVBindShorthand
We got error thrown below
How to reproduce
https://play.vuejs.org/#eNp9UbFOwzAQ/ZXDS5cmGWCKIiRAHWAoCDp6CcnRpCS2ZV/SoCoDCz/Awsa/8QV8AudEbTqgDrZ8997zvWfvxJUxYdugiEXiMlsaAofUmEupogiWmopSrcMwhN/vr3epkmgkMcwFYW2qlJArgOQsCODn4xNWbwYhBcfCCmEWz+AZK72F1EFKZCEIJj6sClSgDW+ZVk6zwCECFX5ZvcUc0Fo9ifKyhRgiLpLoaLyYC3J8w0u5DjdOK46z83wpMl2bskJ7b6jkCVLEMCAeSyv2dTf0yDY43/ezArPXf/ob1/meFA8WHdoWpThglNo10ggvnpbY8fkA1jpvKmafAB+R0zfe40i7blTOto94g9vb2mhL/LQrt+gIlduH8kY9sx/4UvCf3pyIPtk9Dy8GnVS96P8Ayt+tIA==
Summary by CodeRabbit
Bug Fixes
Developer Experience