Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Constructor param typed by a same-file interface is injected as a token (ReferenceError at runtime)

Aperta
#653 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
73/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
angular, rust, typescript
Ambito
compilers

Direzione di ricerca

Start by reading extract_param_token in component/decorator.rs and injectable/decorator.rs, then inspect the copies in the directive, pipe, and ng_module decorators. Compare how those paths handle type-only imports and check the compiler tests for dependency token extraction. Done means same-file interface and type alias parameters produce invalid dependencies and the reported runtime and strict injection behavior is covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

A constructor parameter typed by an interface or type alias that is declared in the same file is compiled as an injection token. The interface is erased, so creating the class throws ReferenceError: Foo is not defined. ngtsc treats the parameter as having no token.

Found while re-checking #623.

Reproduction

import {Injectable} from '@angular/core';

interface Foo { a: number }

@Injectable()
export class S {
  constructor(f: Foo) {}
}
ngtsc 22.2.3 oxc (main 5780233)
full i0.ɵɵinvalidFactory() new (t || S)(i0.ɵɵinject(Foo))
partial deps: "invalid" deps: [{ token: Foo }]
strictInjectionParameters NG2003 error no error

Cause

extract_param_token (component/decorator.rs, injectable/decorator.rs, and the copies in the directive, pipe and ng_module decorators) takes the name of any TSTypeReference and never checks whether that name is a type-only declaration in the file.

A fix can mark the dep invalid when the name is an interface or type declared in the same file, as is already done for type-only imports. An interface imported through a value import from another file can't be detected one file at a time.

Lingua principale
Rust
Stelle
244
Fork
26
Merge medio
23h 41m
PR unite (30g)
106

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di voidzero-dev/oxc-angular-compiler

Tutte le issue di voidzero-dev/oxc-angular-compiler

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.