Skip to content

fix(metadata): fold number consts in a template literal's interpolations - #603

Merged
Brooooooklyn merged 1 commit into
voidzero-dev:mainfrom
encharm:fix/template-literal-number-const
Oct 22, 2026
Merged

Brooooooklyn merged 1 commit into
voidzero-dev:mainfrom
encharm:fix/template-literal-number-const

Conversation

@Rush

@Rush Rush commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

A number in an inline template's interpolation left the component uncompiled:

const WIDTH = 150;
@Component({ selector: 'e-cmp', template: `<canvas style="width: ${WIDTH}px"></canvas>` })

#286 made string consts work; number consts and literals still weren't folded. Like ngtsc's partial evaluator, a ${...} interpolation can now also be a number literal or a same-file number const (negative ones included), converted as JavaScript converts a number to a string (oxc_syntax's ToJsString). Chained consts work too (const SIZE = `${WIDTH}px`).

The number consts are only used for template-literal interpolation: the string-const map used for host bindings, selectors and the rest is unchanged.

tests/template_literal_number_const_test.rs compares the consts of two components with @angular/compiler-cli 21.0.1's: [[1, "box", 2, "width", "150px", "height", "80px"]] and [[2, "width", "150px", "margin", "-2px", "opacity", "0.5"]]. Both fail without the change.

`template: \`<canvas style="width: ${WIDTH}px"></canvas>\`` with
`const WIDTH = 150` left the component uncompiled: only string consts were
folded (voidzero-dev#286). Like ngtsc's partial evaluator, a `${...}` interpolation can now
also be a number literal or a same-file number const (`-2` included), converted
as JavaScript converts numbers to strings.
@Brooooooklyn

Copy link
Copy Markdown
Member

@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-22T14:53:59.373941Z 7e7b8cf Manual request
ℹ️ 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: 7e7b8cf287

ℹ️ 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
@Brooooooklyn
Brooooooklyn merged commit c63f910 into voidzero-dev:main Oct 22, 2026
9 checks passed
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.

2 participants