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

fix(aot): a user binding named `i0` collides with the injected `import * as i0 from '@angular/core'`

Fechada
#509 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
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
68/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 with crates/oxc_angular_compiler/src/component/namespace_registry.rs and compare its alias selection with the JIT handling from #504. Trace the hard-coded i0 uses in class_metadata/compiler.rs and component/transform.rs, including the HMR dependency and emitted import. Done means each file chooses one free namespace alias and the repros no longer produce duplicate bindings or refer to the user's i0.

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

Descrição

bug

In AOT output, OXC always adds import * as i0 from '@angular/core' and refers to it as i0. If the file already has a top-level i0, the output declares it twice (a SyntaxError), and the Ivy code may use the user's i0. ngtsc picks a free name (i0_1). #504 fixed this for the JIT path by choosing a free name. AOT still uses a fixed name.

Repro A

import {Component} from '@angular/core';
const i0 = 1;
@Component({selector: 'c', template: '<div>{{v}}</div>'})
export class C { v = i0; }

Repro B

import {Component} from '@angular/core';
import * as i0 from './other';
@Component({selector: 'c', template: '<div>{{v}}</div>'})
export class C { v = i0.x; }

OXC (main and #504 tip)

import {Component} from '@angular/core';
import * as i0 from '@angular/core';
const i0 = 1;                      // duplicate declaration
export class C { v = i0;
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({...
import * as i0 from './other';
import * as i0 from '@angular/core';   // duplicate import binding

ngtsc 22.1.7

import * as i0_1 from "@angular/core";
const i0 = 1;
export class C {
    v = i0;
    static ɵcmp = /*@__PURE__*/ i0_1.ɵɵdefineComponent({ ... i0_1.ɵɵtext(1); ...

(B: import * as i0 from './other'; import * as i0_1 from "@angular/core";)

Where

i0 is hard-coded in several places:

  • crates/oxc_angular_compiler/src/component/namespace_registry.rs (@angular/core → i0; the iN names for other modules have the same problem)
  • class_metadata/compiler.rs (ReadVarExpr { name: "i0" })
  • component/transform.rs (HMR namespace dependency, and the emitted import)

On main?

Yes. #504 only fixes the JIT path (JIT_ANGULAR_CORE_NS, commit 5128879).

Direction

Pick the namespace alias once per file, avoiding top-level bindings (as #504 does for JIT and as ngtsc's ImportManager does), and pass it to every place that emits the namespace.

Linguagem predominante
Rust
Estrelas
232
Forks
21
Merge médio
1d 18h
PRs com merge (30d)
59

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.