fix(jit): `@Inject` / `@Optional` / `@Attribute` on a class member are dropped instead of lowered to `propDecorators`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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
- スター
- 232
- フォーク
- 21
- 平均マージ
- 2日 14時間
- マージ済み PR(30日)
- 30
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/oxc-angular-compiler のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
voidzero-dev/oxc-angular-compiler#511 ·
メンテナーはふだん 1 日以内に返信
-
question
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
voidzero-dev/oxc-angular-compiler#521 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
voidzero-dev/oxc-angular-compiler#520 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
voidzero-dev/oxc-angular-compiler#519 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
voidzero-dev/oxc-angular-compiler#518 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/oxc-angular-compiler の issue をすべて見る
似ている issue
-
[Misdetection] `text/tab-separated-values` file misdetected as `text/tsv`対応中かも @bact が今日担当しました。 オープンmisdetection needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
C-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
vxc prints a debug line '[flat-codegen] emitted module via the flat path' on every compile対応中かも @YodHeVauHe が今日担当しました。 オープンdevex good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信
-
Unused dependenciesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信