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
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ 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 (4)
✨ 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 |
Adversarial reviewFix matches canonical usage in Must fix before merge:
Worth fixing while here: Out of scope (note for the record):
|
|
Changeset how-to (sorry, should have included this): bunx changeset add
# select @tko/provider.component, pick "patch", paste short description
# commit the generated .changeset/<slug>.md with the fixOr hand-write ---
'@tko/provider.component': patch
---
Fix Parser instantiation and globals in ComponentProvider — globals were silently dropped from component params resolution. |
|
@brianmhunt done |
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.