Skip to content

fix(factory): keep string @Inject tokens in partial mode and for more string forms - #610

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/inject-string-token-followup
Oct 22, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/inject-string-token-followup

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Follow-up to #599. That PR made @Inject('TOKEN') work in full-mode component factories. This PR fixes three cases it left.

Input After #599 Now (same as ngtsc 22.2.2)
partial mode (library build), @Inject('API_URL') deps: [{ token: API_URL }]: a bare name, so a ReferenceError on load, or invalid JS if the string has quotes or is empty deps: [{ token: "API_URL" }]
@Inject('a') @Inject(Svc) on one parameter ɵɵdirectiveInject("Svc"): the string flag from the first @Inject was never reset ɵɵdirectiveInject(Svc): the last @Inject wins
@Inject(`TPL`), @Inject(('X')), @Inject('X' as any) ɵɵinvalidFactoryDep(i) ɵɵdirectiveInject("TPL") / ("X")

Notes:

  • ngtsc keeps a template literal as written (`TPL`). Oxc emits "TPL". The value at runtime is the same.
  • Directives, pipes and injectables already handled these forms; only the component path was missing them.

Not changed: @Inject('a' + 'b') still gives ɵɵinvalidFactoryDep. @Inject(ns.Svc) on a component still falls back to the parameter type; that is how it worked before #599, and it is not a string token.

Tests

  • tests/inject_string_token_test.rs: three new tests, one per row above.
  • New strict compare fixture factory/component-inject-string-token. Its factory matches ngtsc. The fixture's only listed difference is the kept Inject/Optional/Self import, already documented for setClassMetadata.
  • cargo test -p oxc_angular_compiler --all-features: 3491 passed.
  • Conformance: 1264/1264.
  • pnpm compare --fixtures: 1162 fixtures, 0 mismatches.
  • pnpm test: 376 passed.
  • pnpm check passes.

🤖 Generated with Claude Code

… string forms

- Partial compilation declares the token as a string (`deps: [{ token: "API_URL" }]`),
  not a bare identifier that throws or does not parse.
- The last `@Inject` on a parameter decides whether its token is a string, as in ngtsc.
- A template literal with no substitutions, parentheses and TypeScript casts are
  also string tokens.
- Add a strict compare fixture for a component with string tokens.

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-22T07:54:28.267555Z 10efc4f 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 10efc4fc7f

ℹ️ 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".

@Brooooooklyn
Brooooooklyn merged commit c0ea964 into main Oct 22, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/inject-string-token-followup branch October 22, 2026 08:16
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