Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix(jit): `@Inject` / `@Optional` / `@Attribute` on a class member are dropped instead of lowered to `propDecorators`

Đang mở
#522 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

bug

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của voidzero-dev/oxc-angular-compiler

Tất cả issue của voidzero-dev/oxc-angular-compiler

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.