fix(nuxt): handle TS type assertions on member expression callees in keyed functions parser#34558
Conversation
…keyed functions parser Extend `parseStaticFunctionCall` to unwrap `TSAsExpression`, `TSTypeAssertion`, and `TSNonNullExpression` when they wrap a member expression inside a parenthesized callee. Without this, patterns like `(factories.createUseFetch as any)()` silently skip key injection.
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis change extends the 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Merging this PR will not alter performance
Comparing Footnotes
|
…keyed functions parser (#34558)
…keyed functions parser (#34558)
parseStaticFunctionCallalready unwraps TS type assertions (as, angle-bracket casts,!) for simple callees like(useFetch as any)(), and it handles member expressions likefactories.createUseFetch(). But when both are combined - a parenthesized type assertion wrapping a member expression - the parser bails and returns null.That means patterns like
(factories.createUseFetch as any)(),(factories.createUseFetch!)(), or(<any>factories.createUseFetch)()never get a key injected by the compiler, which can lead to state collisions or hydration mismatches at runtime.The fix unwraps one layer of TS assertion inside the parenthesized expression before checking for a member expression, same approach already used for the simple callee branch. Resolves the TODO on the same line.