Decide: `@Injectable` imported under an alias — ngtsc emits no `ɵfac`, OXC does
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- angular, rust, typescript
- Área
- compilers
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 232
- Forks
- 21
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 59
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de voidzero-dev/oxc-angular-compiler
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
voidzero-dev/oxc-angular-compiler#563 ·
Los mantenedores suelen responder en 1 día
-
e2e compare: setClassMetadata extraction regex never matches (ɵɵ vs ɵ) — classMetadataDiffs is dead codePosiblemente ocupada @Brooooooklyn la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
voidzero-dev/oxc-angular-compiler#561 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
voidzero-dev/oxc-angular-compiler#506 ·
Los mantenedores suelen responder en 1 día
-
fix(directive): input names with lone surrogates are emitted in oxc's internal U+FFFD encodingAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
voidzero-dev/oxc-angular-compiler#505 ·
Los mantenedores suelen responder en 1 día
-
bug rust
Dificultad 4/5 3-5 días Aptitud para principiantes 56/100
voidzero-dev/oxc-angular-compiler#313 ·
Los mantenedores suelen responder en 1 día
Todos los issues de voidzero-dev/oxc-angular-compiler
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
curator: add tutros/sbxmAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
ajeetraina/awesome-docker-sbx#220 ·
-
`helios / deploy`: switch zone wait in `deploy.sh` has almost no headroom over healthy startup timesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoTest Flake
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
oxidecomputer/omicron#11453 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/adaptive-apps#58 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día