Decide: `@Injectable` imported under an alias — ngtsc emits no `ɵfac`, OXC does
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá 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
Compare the alias case in the issue with ngtsc’s needsFactory logic in packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts. Review the OXC output and decide whether to preserve its working factory or match ngtsc; if keeping OXC’s behavior, record the difference in napi/angular-compiler/e2e/compare/fixtures/known-differences.ts. Done means the behavior decision is reflected in the fixture list.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
With #504, OXC finds Angular class decorators by their @angular/core import, so an aliased @Injectable is now compiled. ngtsc 22.1.7 compiles it differently. It looks like an ngtsc bug. This issue records the difference and asks whether we keep OXC's output.
Repro
import {Injectable as X} from '@angular/core';
@X({providedIn: 'root'})
export class S {}
ngtsc 22.1.7
export class S {
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: S, factory: S.ɵfac, providedIn: 'root' });
}
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
No ɵfac and no setClassMetadata. ɵprov.factory points at S.ɵfac, which doesn't exist, so injecting S fails at runtime.
Cause, in packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts:
needsFactory:
meta.decorators === null ||
decorators.every((current) => !isAngularCore(current) || current.name === 'Injectable'),
current.name is the name as written (X), so an aliased import gives needsFactory = false. setClassMetadata is only emitted inside if (analysis.needsFactory), so it is dropped too.
OXC (#504 tip)
export class S {
static ɵfac = /*@__PURE__*/ (() =>{
let ɵS_BaseFactory;
return function S_Factory(__ngFactoryType__) {
return (ɵS_BaseFactory || (ɵS_BaseFactory = i0.ɵɵgetInheritedFactory(S)))((__ngFactoryType__ || S));
};
})();
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({token:S,factory:S.ɵfac,providedIn:"root"});
}
// + ɵsetClassMetadata(S,[{type:X,args:[{providedIn:"root"}]}],null,null)
static ɵfac: i0.ɵɵFactoryDeclaration<S, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<S>;
On main the aliased decorator is not recognized at all, so the class is left as written (@X({providedIn: 'root'}) export class S {}).
Decision needed
- Keep OXC's output (a working factory). This is a known difference from ngtsc. Add it to
napi/angular-compiler/e2e/compare/fixtures/known-differences.ts. - Or copy ngtsc's output exactly. That gives a broken
ɵprov.
Recommendation: keep it, record the difference, and maybe report it upstream.
Note: the ɵgetInheritedFactory form and InjectableDeclaration<S> vs <any> also show up for a plain @Injectable() class with no constructor, on main too. Not specific to the alias.
- Ngôn ngữ chính
- Rust
- Star
- 232
- Fork
- 21
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 59
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
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
voidzero-dev/oxc-angular-compiler#563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e compare: setClassMetadata extraction regex never matches (ɵɵ vs ɵ) — classMetadataDiffs is dead codeCó thể đã có người làm @Brooooooklyn đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
voidzero-dev/oxc-angular-compiler#561 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
voidzero-dev/oxc-angular-compiler#506 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(directive): input names with lone surrogates are emitted in oxc's internal U+FFFD encodingĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
voidzero-dev/oxc-angular-compiler#505 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug rust
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
voidzero-dev/oxc-angular-compiler#313 ·
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ự
-
agent:triaged bug bughunt pm:npm priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#1127 · 1 bình luận ·
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 65/100
-
documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
adorsys/status-list-server#619 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
batch-backport only backports the first 30 matching PRsCó thể đã có người làm @DvirDukhan đã nhận hôm nay. Đang mở
Độ 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 5 ngày
-
Configuration-level resource: `Allocate` rejects the kubelet's re-offer of the same device for a later container of the same Pod ("Unable to claim slot")Có thể đã có người làm @fang80913 đã nhận 38 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
project-akri/akri#854 ·