Repository navigation
fix(compiler): report missing ngtsc diagnostics for inputs, outputs, queries and signal APIs - #559
Conversation
…queries and signal APIs Implements the ngtsc diagnostics issue #508 lists (vendored Angular 22.0.0 semantics): - NG8110 source-file rule for initializer APIs used outside a class member initializer (new src/validation.rs), incl. upstream quirks: parens/`as` wrapping escapes the check, `!`/`satisfies` trigger it, `.required` shows in the message, and callee identifiers are resolved through oxc_semantic so shadowed locals and params do not false-positive. - NG1053 disallowed member visibility (private / ES private) for signal input/model/output/query initializers; queries keep allowing TS `private`. - NG1010 for signal options: a non-literal `alias` and a non-object options argument. - NG1054 duplicate input/output binding names, with the first binding labeled as related. - NG1006 for combining multiple query decorators or a query decorator with an `@Input`-named decorator. - NG2004 `selector: ''` on @directive; `selector must be a string` for both components and directives. - `@Output` on setters/getters/methods now emits its `outputs` entry. - Members whose names can't be reflected (computed/numeric keys) are skipped in the io/query passes and emit paths like upstream's reflectClassMember; `#x` members keep their checks. Existing checks were reordered where upstream throws them in a different sequence (signal access/options errors before decorator collisions, duplicate-binding before static for inputs but after for outputs, decorator collisions before the member-kind query check).
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: 0001908c9e
ℹ️ 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".
…odel The class-decorator check still used the file-wide import map, so a shadowed `Directive` identifier (e.g. a function parameter) counted as Angular's and suppressed the diagnostic. Resolve the decorator callee to its binding like `is_api_reference` does for the call, matching upstream's `decorator.import?.from`.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7b1204514
ℹ️ 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".
`extract_view_queries_in`/`extract_content_queries_in` still named
members with `get_property_key_name`, which accepts a string-literal
key on a computed member — `['q'] = viewChild('x')` emitted a query
while the new member guards skip validation for it. Use
`member_name_ident` (the reflectClassMember-equivalent) in every
extraction arm so computed and numeric members produce no query.
Fixes #508.
Implements the ngtsc diagnostics the issue lists, matching vendored Angular 22.0.0 semantics (
ngtsc/annotations/directive/src/shared.ts,initializer_function_access.ts,input_output_parse_options.ts,ngtsc/validation/src/rules/initializer_api_usage_rule.ts).Diagnostics added
@Component/@Directivemember initializerUnsupported call to the {fn} function. This function can only be called in the initializer of a class member.(or the…initializer of a property on a @Component or @Directive class.variant)private/#privatememberCannot use "{fn}" on a class member that is declared as {level}.+ allowed-levels chainalias/ non-object options argAlias needs to be a string that is statically analyzable./Argument needs to be an object literal that is statically analyzable.@Input+ query decoratorCannot combine multiple query decorators./Cannot combine @Input decorators with query decorators@Directive({selector: ''})Directive {D} has no selector, please add it!selector(component and directive)selector must be a string+ wrong-type suffixBehavior changes
@Outputon a setter/getter/method now emits itsoutputsentry (@Output() set o(v)→outputs:{o:"o"}).['k'], numeric0:) are skipped in io/query passes and emit paths, matching upstreamreflectClassMember;#xmembers keep their checks.Upstream quirks preserved
(input(0))andinput(0) as anyescape NG8110 entirely;input(0)!andsatisfiestrigger it.oxc_semantic, so a local/param shadowinginputor a core namespace doesn't false-positive.@In(aliased import) doesn't trigger the@Input-query collision; the written name must beInput.alias: LOCAL_CONSTerrors — the options object isn't evaluated for signal APIs.Verified
cargo test -p oxc_angular_compiler --all-features— all pass (incl. new regression tests for each diagnostic and edge case)cargo run -p oxc_angular_conformance—Total: 1264/1264 (100.0%)pnpm testinnapi/angular-compiler— 401/401cargo fmt --all -- --checkclean; no new clippy warnings