Skip to content

fix(metadata): read selector, exportAs and kept metadata fields with the partial evaluator - #613

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/template-literal-evaluator-followup
Oct 23, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/template-literal-evaluator-followup

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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 partial Evaluator already folds were still dropped:

  • +5 and const V = +5
  • W * 2 and 1 / 3
  • an aliased const (const W = BASE)
  • an enum member, or an imported const
  • a let or var declaration
  • true / null / undefined

The narrower folder is still used by selector, exportAs and the check that decides which fields setClassMetadata keeps. For those forms:

Field ngtsc 22.2.2 Before
selector: \x-${W * 2}`` selectors: [["x-300"]] selectors: [["ng-component"]]; a @Directive gets no selector, so it never matches
exportAs: \e${+W}`` exportAs: ["e150"] no exportAs
setClassMetadata keeps selector, exportAs, template, styles as written drops them

Those three, and the JIT rewrite of templateUrl / styleUrl / styleUrls, now read the value with evaluate_string_value, the way template is already read: the const folder first, then the Evaluator. One reader decides both what is compiled and what setClassMetadata keeps, so the two can't disagree. The number map from #603 is no longer needed and is removed. Its tests still pass through the Evaluator.

Across 27 forms, setClassMetadata args, selectors and exportAs all 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 &'a borrows, because the Evaluator needs them. Every caller already had them.

Tests

  • tests/template_literal_number_const_test.rs: a new test for ${W * 2} / ${+W}, where W is an alias of another const. It checks the selector, exportAs and the kept setClassMetadata fields, and fails without the change.
  • jit_resource_urls_with_number_interpolation: JIT templateUrl / styleUrl / styleUrls with ${1}, a number const and ${V * 2}. Codex found this case on this PR.
  • cargo test -p oxc_angular_compiler --all-features: 3503 passed.
  • Conformance: 1264/1264.
  • pnpm compare --fixtures: 1162 fixtures, 0 mismatches.
  • pnpm test: 376 passed.
  • No new clippy warnings on the changed lines.

🤖 Generated with Claude Code

…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>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T15:45:43.881732Z a35b6be New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/oxc_angular_compiler/src/directive/decorator.rs
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>
@Brooooooklyn
Brooooooklyn merged commit b8628c4 into main Oct 23, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/template-literal-evaluator-followup branch October 23, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant