Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Tracking: evaluate decorator metadata values imported from other files

Abierto
#518 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
angular, rust, typescript
Área
compilers

Línea de trabajo

Start in crates/oxc_angular_compiler/src/directive/decorator.rs around the reported error and read directive/evaluator.rs. Compare the resolver and dependency handling in component/cross_file_elision.rs with TransformOptions::resolved_imports and the Vite transform path. A complete direction should define how imported literal values are evaluated, dependent files are re-transformed, and unsupported cases retain a clear fallback.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement

OXC compiles one file at a time. ngtsc has the whole program, so its static evaluator follows an import into the other file and reads the value. OXC can't do that. Since #493 (fix/decorator-metadata-inputs-outputs) and #495 (feat/decorator-metadata-queries), OXC reports a clear error in these cases. Main silently emits wrong metadata.

Error: @Directive.inputs depends on 'INPUTS', which is imported from another module. OXC compiles one file at a time and cannot evaluate values from other files.

This issue tracks the gap and possible ways to close it.

Affected forms (other.ts exports a plain const)

Source ngtsc 22.1.7 OXC #504 tip OXC main
@Directive({inputs: INPUTS}), INPUTS = ['a'] inputs: { a: "a" } error input dropped (no inputs)
@Directive({inputs: [NAME]}), NAME = 'a' inputs: { a: "a" } error input dropped
@Directive({outputs: OUTPUTS}), OUTPUTS = ['o: oo'] outputs: { o: "oo" } error output dropped
@Input(OPTS) a, OPTS = {alias: 'b', required: true} inputs: { a: [0, "b", "a"] } ("required": true in .d.ts) error inputs:{a:"a"} (alias and required ignored)
@Input({alias: ALIAS}) a, ALIAS = 'b' inputs: { a: [0, "b", "a"] } error inputs:{a:"a"}
@Output(ONAME) o, ONAME = 'oo' outputs: { o: "oo" } error outputs:{o:"o"}
@ViewChild('a', {static: STATIC}), STATIC = true ɵɵviewQuery(_c0, 7) error ɵɵviewQuery(_c0,5) (not static)
@Input({transform: T}), T a function in other.ts .d.ts: ngAcceptInputType_a: string ngAcceptInputType_a: unknown unknown
@ViewChild(SEL), SEL = 'a' ɵɵviewQuery(_c0, 5), _c0 = ["a"] ɵɵviewQuery(SEL,5) same as tip

The last row works at runtime (ɵɵviewQuery accepts a string predicate), so only the shape differs.

These are not gaps, because ngtsc rejects them too and the tip matches it:

  • @ViewChild('a', QOPTS) → NG1001: @ViewChild options must be an object literal
  • queries: Q → NG1010: Decorator queries metadata must be an object literal
  • input(0, {alias: ALIAS}) → NG1010: Alias needs to be a string that is statically analyzable. (OXC misses this one; it's in the diagnostics issue)

Example:

// test.ts
import {Directive} from '@angular/core';
import {INPUTS} from './other';
@Directive({selector: '[d]', inputs: INPUTS})
export class D { a: any; }

// other.ts
export const INPUTS = ['a'];

Where

  • The error comes from crates/oxc_angular_compiler/src/directive/decorator.rs (~L706). The static evaluator is directive/evaluator.rs. Both are in the stack.

Possible approaches (not decided)

  1. Resolver hook from the Vite plugin. transformAngularFile takes a callback, or a precomputed map, that returns the value of an imported binding (specifier + exportName). The plugin resolves with Vite's resolver and reads the file. There is already a similar input, TransformOptions::resolved_imports (identifier → path), which only rewrites import paths today.
  2. Reuse component/cross_file_elision.rs. Behind the cross_file_elision feature (off by default, "intended for compare test purposes only") it already resolves imports with oxc_resolver (tsconfig paths included), parses the target with oxc_parser, and walks re-exports. It could be extended to evaluate exported const initializers and feed the result to the evaluator.
  3. Leave it as is. Keep the error and document the workaround: inline the value, or declare it in the same file.

For 1 and 2: the importing file has to be re-transformed when the other file changes. TransformResult::dependencies exists today for template and style files, and the Vite plugin links some of them to this.addWatchFile. A dependency on another file's value would need the same kind of wiring. Cycles, re-exports, export *, values that are not literals, and .d.ts-only packages need a defined fallback (keep today's error).

Lenguaje dominante
Rust
Estrellas
232
Forks
21
Merge medio
2 d 14 h
PR fusionados (30 d)
30

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de voidzero-dev/oxc-angular-compiler

Todos los issues de voidzero-dev/oxc-angular-compiler

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.