fix(jit): `@Inject` / `@Optional` / `@Attribute` on a class member are dropped instead of lowered to `propDecorators`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- angular, rust, typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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().
- Ngôn ngữ chính
- Rust
- Star
- 232
- Fork
- 21
- Merge trung bình
- 2 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/oxc-angular-compiler
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
voidzero-dev/oxc-angular-compiler#511 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#521 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
voidzero-dev/oxc-angular-compiler#520 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
voidzero-dev/oxc-angular-compiler#519 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#518 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/oxc-angular-compiler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
install: root SSH tmpfiles.d drop-in is labeled etc_runtime_t instead of etc_tCó thể đã có người làm @andrewdunndev đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Misdetection] `text/tab-separated-values` file misdetected as `text/tsv`Có thể đã có người làm @bact đã nhận hôm nay. Đang mởmisdetection needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
C-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày