Fix Parser instantiation and globals in ComponentProvider#362
Fix Parser instantiation and globals in ComponentProvider#362
Conversation
Remove `as any` downcast on Parser constructor. Parser takes no constructor arguments; context, globals, and node are parameters of `.parse()`. The old code silently dropped `this.globals` (passed to the no-op constructor) and sent `undefined` to `.parse()`, so global variables could not resolve in component params. Add test that exercises globals resolution through component params. Adversarial review: subagent audit — no backwards-compat, disposal, perf, or API surface concerns; fix aligns with every other provider.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 10 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary
ComponentProvider.getComponentParamswas instantiatingParserwith a downcast (new (Parser as any)(node, context, this.globals)) and passingundefinedas globals to.parse(). SinceParsertakes no constructor arguments, the globals were silently dropped — global variables could never resolve in component params.Changes
ComponentProvider.ts: Replacenew (Parser as any)(node, context, this.globals) as Parserwithnew Parser(), and passthis.globalsto.parse()instead ofundefined. This matches how every other provider (BindingStringProvider,mustacheParser) usesParser.componentProviderBehaviors.ts: Add test that registers a component withparams="answer: GLOBAL_CONST"whereGLOBAL_CONSTis provided via provider globals, verifying globals resolution in component params.Verification
All 52 existing tests pass (chromium + happy-dom). New test passes in both environments.