Missing ngtsc diagnostics for invalid inputs, outputs, queries and signal APIs
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- angular, rust, typescript
- 领域
- compilers
调研方向
Start in crates/oxc_angular_compiler/src/directive/property_decorators.rs and directive/decorator.rs, then compare the corresponding ngtsc checks in shared.ts and input_output_parse_options.ts. Review initializer_api_usage_rule.ts for NG8110. Use the checklist snippets as repro cases; done means the expected diagnostics are emitted and the incorrect bindings, queries, and metadata are no longer produced.
由索引模型根据 Issue 内容生成。
描述
ngtsc 22.1.7 rejects each form below. OXC (main and #504 tip, 3e0b07f) compiles them with no diagnostic. Often the output is wrong too: a binding is dropped, duplicated, or a query is registered twice.
Each snippet uses import {Component, Directive, Input, Output, EventEmitter, ViewChild, ContentChild, input, output, viewChild, model} from '@angular/core';.
Checklist
ngtsc message is exact (codes shown as NGxxxx). The OXC column is #504 tip; main is the same.
- Decorator on a signal query.
@ViewChild('a') q = viewChild('a');
ngtsc:NG1050: Using @ViewChild with a signal-based query is not allowed.(same for@ContentChildetc.)
OXC: no error. Emits a decoratorɵɵviewQuery. -
input()/model()not used directly as a field initializer.a = input(0)!;,m = model(0)!;,a = input(0) satisfies any;,constructor() { const x = input(0); }
ngtsc:NG8110: Unsupported call to the input function. This function can only be called in the initializer of a class member.(modelgives "...the model function...")
OXC: no error. The input is silently left out ofinputs. - Signal API on a
private/#privatemember.private a = input(0);/#a = input(0);
ngtsc:NG1053: Cannot use "input" on a class member that is declared as private. Update the class field to be either: public, public readonly, protected(... declared as ES private. ...for#a)
OXC: no error.privatecompiles as a normal input.#ais silently dropped. - Signal option alias is not a string literal.
a = input(0, {alias: 1 as any});,o = output({alias: 1 as any});, andinput(0, {alias: ALIAS})withALIASimported from another file
ngtsc:NG1010: Alias needs to be a string that is statically analyzable.
OXC: no error. The alias is ignored (inputs:{a:[1,"a"]},outputs:{o:"o"}). - Two members bound to the same public name.
@Input('y') x: any; @Input() y: any;
ngtsc:NG1054: Input 'y' is bound to both 'x' and 'y'.
Same for outputs:NG1054: Output 'y' is bound to both 'x' and 'y'.
OXC: no error. Both are emitted (outputs:{x:"y",y:"y"}). - Two query decorators on one member.
@ViewChild('a') @ContentChild('b') q: any;
ngtsc:NG1006: Cannot combine multiple query decorators.
OXC: no error. Emits both acontentQueryand aviewQuerywriting toctx.q. -
@Inputtogether with a query decorator.@Input() @ViewChild('a') q: any;
ngtsc:NG1006: Cannot combine @Input decorators with query decorators
OXC: no error. Emits bothinputs:{q:"q"}and aviewQuery. - Static members.
@Input() static a: any;→NG1100: Input "a" is incorrectly declared as static member of "D".@ViewChild('a') static q: any;→NG1100: Query is incorrectly declared on a static class member.@Output() static o = new EventEmitter();→NG1100: Output is incorrectly declared on a static class member.
OXC: no error. All three are emitted as if they were instance members.
-
@Output()on a setter.@Output() set o(v: any) {}
ngtsc compiles it:outputs: { o: "o" }. With a bad argument,@Output(1 as any) set o(v: any) {}, it reportsNG1010: @Output decorator argument must resolve to a string Value is of type 'number'.
OXC: drops the output (nooutputs,{}in.d.ts) and does not check the argument. - Directive with
selector: ''.@Directive({selector: ''}) export class D {}
ngtsc:NG2004: Directive D has no selector, please add it!
OXC: no error. EmitsɵɵdefineDirective({type:D})and""as the.d.tsselector. (Components withselector: ''are tracked separately.)
Where ngtsc raises them (Angular v22.0.0 source)
packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.ts: NG2004, NG1006 ×2, NG1054 ×2, NG1100 ×3, NG1050.../annotations/directive/src/initializer_function_access.ts: NG1053.../annotations/directive/src/input_output_parse_options.ts: alias NG1010.../validation/src/rules/initializer_api_usage_rule.ts: NG8110 (a source-file check, not part of the decorator handler)
On the OXC side, most belong in crates/oxc_angular_compiler/src/directive/property_decorators.rs and directive/decorator.rs.
On main?
Yes, all of them. The stack doesn't change these cases.
- 主要语言
- Rust
- 星标
- 232
- 派生
- 21
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 53
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/oxc-angular-compiler 的其他 Issue
-
fix(emit): spread arguments in calls and `new` are dropped (`f(...P)` → `f(P)`)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 85/100
voidzero-dev/oxc-angular-compiler#511 ·
维护者通常 1 天内回复
-
fix(emit): arrow functions in metadata lose default parameter values and `async`可能已有人在做 @Brooooooklyn 今天认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 58/100
voidzero-dev/oxc-angular-compiler#512 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 78/100
voidzero-dev/oxc-angular-compiler#510 ·
维护者通常 1 天内回复
-
fix(aot): a user binding named `i0` collides with the injected `import * as i0 from '@angular/core'`未关闭bug
难度 4/5 3-5 天 新手友好度 68/100
voidzero-dev/oxc-angular-compiler#509 ·
维护者通常 1 天内回复
-
question
难度 4/5 3-5 天 新手友好度 45/100
voidzero-dev/oxc-angular-compiler#507 ·
维护者通常 1 天内回复
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
bmander/geomsolver#118 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
Three Windows builds are keyed on a later release than their layout可能已有人在做 @ero-qt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
priority:P3 type:docs
难度 2/5 1-3 小时 新手友好度 85/100
sebastian-software/ferroni#253 ·
维护者通常 1 天内回复