Decide: `@Injectable` imported under an alias — ngtsc emits no `ɵfac`, OXC does
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- angular, rust, typescript
- 领域
- compilers
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- 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 于 220 天前认领,目前没有进行中的 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 于 220 天前认领,目前没有进行中的 PR。 未关闭
voidzero-dev/oxc-angular-compiler#60 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
C-bug
难度 2/5 1-3 小时 新手友好度 78/100
rust-lang/rust-analyzer#23501 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[Bug]: Web chat input doesn't regain focus after a reply finishes可能已有人在做 @GaijinSystems 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
zeroclaw-labs/zeroclaw#11658 ·
维护者通常 2 天内回复
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 82/100
bytecodealliance/wasm-tools#2768 ·
维护者通常 1 天内回复