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

fix(jit): `@Inject` / `@Optional` / `@Attribute` on a class member are dropped instead of lowered to `propDecorators`

Aperta
#522 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
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
angular, rust, typescript
Ambito
compilers

Direzione di ricerca

Start in component/transform.rs near ANGULAR_DECORATOR_NAMES and inspect the JIT member-decorator lowering logic. Run the reproducer with transformAngularFileSync and compare its output with the expected ngtsc shape. Done means every @angular/core member decorator is retained in static propDecorators, in order, including mixed members, while same-named decorators from other modules remain unchanged.

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

Descrizione

bug

In JIT mode (jit: true), OXC drops @angular/core member decorators that are not field decorators. Examples are @Inject, @Optional, @Attribute, @Self, @Host, and @Component on a member. ngtsc's JIT transform (downlevel_decorators_transform) lowers every member decorator imported from @angular/core into static propDecorators. It does not check the decorator name.

The code says this on purpose (component/transform.rs, near ANGULAR_DECORATOR_NAMES):

// Angular non-field decorators (e.g. @Inject on a member) are silently dropped
// since they have no meaningful effect on members.

Angular's own JIT compiler ignores these entries. But code that reads propDecorators (for example ReflectionCapabilities.propMetadata, or custom tools) sees a different result. The output is not 1:1 with ngtsc.

Repro

// tokens.ts
import {InjectionToken} from '@angular/core';
export const TOKEN = new InjectionToken<unknown>('T');

// test.ts
import {Component, Inject, Optional, Attribute} from '@angular/core';
import {TOKEN} from './tokens';
@Component({selector: 'c', template: ''})
export class C {
  @Inject(TOKEN) @Optional() x: unknown;
  @Attribute('a') y: unknown;
}

OXC (transformAngularFileSync(src, file, { jit: true }), main d34d9b9)

import { Component, Inject, Optional, Attribute } from "@angular/core";
import { TOKEN } from "./tokens";
import { __decorate } from "tslib";
let C = class C {
	x;
	y;
};
C = __decorate([Component({
	selector: "c",
	template: ""
})], C);
export { C };

ngtsc 22.1.7 (constructorParametersDownlevelTransform, which @angular/build uses for JIT)

import { Component, Inject, Optional, Attribute } from '@angular/core';
import { TOKEN } from './tokens';
let C = class C {
    static { this.propDecorators = {
        x: [{ type: Inject, args: [TOKEN,] }, { type: Optional }],
        y: [{ type: Attribute, args: ['a',] }]
    }; }
};
C = __decorate([
    Component({ selector: 'c', template: '' })
], C);
export { C };

Expected

Lower every member decorator imported from @angular/core into propDecorators, like ngtsc's isAngularDecorator (decorator.import.from === "@angular/core"). Keep the decorator order. A mixed member (@Input() @Inject(T) x) must keep both entries. Today OXC keeps only Input.

Found during the review of #504. #504 already makes the member decorator check import-aware: a same-named decorator from another module stays in __decorate().

Lingua principale
Rust
Stelle
228
Fork
20
Merge medio
2g 14h
PR unite (30g)
30

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.