fix(jit): `@Inject` / `@Optional` / `@Attribute` on a class member are dropped instead of lowered to `propDecorators`
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- angular, rust, typescript
- 領域
- compilers
研究方向
Start in component/transform.rs near ANGULAR_DECORATOR_NAMES and inspect the JIT member-decorator lowering logic. Run the reproducer with transformAngularFileSync and compare its output with the expected ngtsc shape. Done means every @angular/core member decorator is retained in static propDecorators, in order, including mixed members, while same-named decorators from other modules remain unchanged.
由索引模型根據 Issue 內容生成。
描述
In JIT mode (jit: true), OXC drops @angular/core member decorators that are not field decorators. Examples are @Inject, @Optional, @Attribute, @Self, @Host, and @Component on a member. ngtsc's JIT transform (downlevel_decorators_transform) lowers every member decorator imported from @angular/core into static propDecorators. It does not check the decorator name.
The code says this on purpose (component/transform.rs, near ANGULAR_DECORATOR_NAMES):
// Angular non-field decorators (e.g. @Inject on a member) are silently dropped
// since they have no meaningful effect on members.
Angular's own JIT compiler ignores these entries. But code that reads propDecorators (for example ReflectionCapabilities.propMetadata, or custom tools) sees a different result. The output is not 1:1 with ngtsc.
Repro
// tokens.ts
import {InjectionToken} from '@angular/core';
export const TOKEN = new InjectionToken<unknown>('T');
// test.ts
import {Component, Inject, Optional, Attribute} from '@angular/core';
import {TOKEN} from './tokens';
@Component({selector: 'c', template: ''})
export class C {
@Inject(TOKEN) @Optional() x: unknown;
@Attribute('a') y: unknown;
}
OXC (transformAngularFileSync(src, file, { jit: true }), main d34d9b9)
import { Component, Inject, Optional, Attribute } from "@angular/core";
import { TOKEN } from "./tokens";
import { __decorate } from "tslib";
let C = class C {
x;
y;
};
C = __decorate([Component({
selector: "c",
template: ""
})], C);
export { C };
ngtsc 22.1.7 (constructorParametersDownlevelTransform, which @angular/build uses for JIT)
import { Component, Inject, Optional, Attribute } from '@angular/core';
import { TOKEN } from './tokens';
let C = class C {
static { this.propDecorators = {
x: [{ type: Inject, args: [TOKEN,] }, { type: Optional }],
y: [{ type: Attribute, args: ['a',] }]
}; }
};
C = __decorate([
Component({ selector: 'c', template: '' })
], C);
export { C };
Expected
Lower every member decorator imported from @angular/core into propDecorators, like ngtsc's isAngularDecorator (decorator.import.from === "@angular/core"). Keep the decorator order. A mixed member (@Input() @Inject(T) x) must keep both entries. Today OXC keeps only Input.
Found during the review of #504. #504 already makes the member decorator check import-aware: a same-named decorator from another module stays in __decorate().
- 主要語言
- Rust
- 星號
- 235
- 分支
- 21
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 65
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/oxc-angular-compiler 的其他 Issue
-
bug
難度 4/5 3-5 天 新手友好度 68/100
voidzero-dev/oxc-angular-compiler#505 ·
維護者通常 1 天內回覆
-
bug rust
難度 4/5 3-5 天 新手友好度 56/100
voidzero-dev/oxc-angular-compiler#313 ·
維護者通常 1 天內回覆
-
Support useDefineForClassFields: false (Class Field Lowering)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 5/5 一週以上 新手友好度 35/100
voidzero-dev/oxc-angular-compiler#73 · 11 則留言 ·
維護者通常 1 天內回覆
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR runtime parity regressions (RouterLinkActive, Forms DI, Apollo DI) require app-level shims可能重新可做 @Brooooooklyn 於 225 天前認領,目前沒有進行中的 PR。 未關閉
voidzero-dev/oxc-angular-compiler#61 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR: AngularNodeAppEngine is unusable (missing app-engine manifest)可能重新可做 @Brooooooklyn 於 225 天前認領,目前沒有進行中的 PR。 未關閉
voidzero-dev/oxc-angular-compiler#60 · 4 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
agent:triaged bug bughunt pm:bundler priority:p1
難度 2/5 1-3 小時 新手友好度 70/100
SocketDev/socket-patch#1573 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
bytecodealliance/rustix#1706 · 1 則留言 ·
維護者通常 11 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
-
難度 2/5 1-3 小時 新手友好度 72/100
wormhole-foundation/wormhole#5062 ·
維護者通常 1 天內回覆
-
LaunchOrFocusPlugin switches to the wrong tab after tabs are reordered (tab id used as position)可能已有人在做 @olegator888 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
zellij-org/zellij#5719 ·
維護者通常 1 天內回覆