Repository navigation
fix(metadata): read selector, exportAs and kept metadata fields with the partial evaluator - #613
Merged
Merged
Conversation
…the partial evaluator
`selector`, `exportAs` and the check that decides which template-literal fields
setClassMetadata keeps now read their value with `evaluate_string_value`, like
`template` already does: the const folder first, then the partial evaluator.
A template literal that only the evaluator can fold (`${+W}`, `${W * 2}`, an
aliased or imported const, an enum member, `let`/`var`, `true`/`null`) now gives
the folded selector and exportAs and keeps its fields in setClassMetadata, as
in ngtsc. The narrower number map is no longer needed and is removed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb8ebbf955
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The JIT rewrite of `templateUrl`, `styleUrl` and `styleUrls` reads the URL with
`evaluate_string_value` too, so a number interpolation (`./v${1}.html`, a
number const, `${V * 2}`) still folds now that the narrower number map is gone,
and JIT accepts the same shapes as AOT.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #603. That PR folds number consts and number literals in a template literal's
${...}with a new number map. Other forms the partialEvaluatoralready folds were still dropped:+5andconst V = +5W * 2and1 / 3const W = BASE)letorvardeclarationtrue/null/undefinedThe narrower folder is still used by
selector,exportAsand the check that decides which fieldssetClassMetadatakeeps. For those forms:selector: \x-${W * 2}``selectors: [["x-300"]]selectors: [["ng-component"]]; a@Directivegets no selector, so it never matchesexportAs: \e${+W}``exportAs: ["e150"]exportAssetClassMetadataselector,exportAs,template,stylesas writtenThose three, and the JIT rewrite of
templateUrl/styleUrl/styleUrls, now read the value withevaluate_string_value, the waytemplateis already read: the const folder first, then theEvaluator. One reader decides both what is compiled and whatsetClassMetadatakeeps, so the two can't disagree. The number map from #603 is no longer needed and is removed. Its tests still pass through theEvaluator.Across 27 forms,
setClassMetadataargs,selectorsandexportAsall match ngtsc 22.2.2. #603 alone matched 5 of them. NaN, Infinity and undeclared names behave as they did before. This also fixes the aliased-const case Codex found on #603 (thread).build_decorator_metadata_array,build_ctor_params_metadata(_in),build_prop_decorators_metadata(_in)and two private JIT helpers now take&'aborrows, because theEvaluatorneeds them. Every caller already had them.Tests
tests/template_literal_number_const_test.rs: a new test for${W * 2}/${+W}, whereWis an alias of another const. It checks the selector,exportAsand the keptsetClassMetadatafields, and fails without the change.jit_resource_urls_with_number_interpolation: JITtemplateUrl/styleUrl/styleUrlswith${1}, a number const and${V * 2}. Codex found this case on this PR.cargo test -p oxc_angular_compiler --all-features: 3503 passed.pnpm compare --fixtures: 1162 fixtures, 0 mismatches.pnpm test: 376 passed.🤖 Generated with Claude Code