Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#653 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
73/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
angular, rust, typescript
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Rust
Estrelas
244
Forks
26
Merge médio
23h 41min
PRs com merge (30d)
106

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de voidzero-dev/oxc-angular-compiler

Todas as issues de voidzero-dev/oxc-angular-compiler

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.