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

fix(emit): `(v) => ({value: v}).value` is printed as invalid `(v) =>{value:v}.value`

Cerrado
#510 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
angular, rust
Área
compilers

Línea de trabajo

Start in crates/oxc_angular_compiler/src/output/emitter.rs around the main lines ~742 and ~766, focusing on OutputExpression::Parenthesized and the ArrowFunction arm. Trace how nested member-access, call, or other receivers are emitted, then verify that an object literal at the body's leftmost token retains parentheses and produces valid JavaScript for the supplied reproductions.

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

Descripción

bug

When an arrow body starts with a parenthesized object literal but isn't only that object (member access, call, and so on), the emitter drops the parentheses. The output is invalid JS, or JS with a different meaning.

Repro (input transform)

import {Directive, Input} from '@angular/core';
@Directive({selector: '[d]'})
export class D {
  @Input({transform: (v: any) => ({value: v}).value}) a: any;
}

Repro (provider factory)

import {Component} from '@angular/core';
@Component({selector: 'c', template: '', providers: [{provide: 'T', useFactory: () => ({a: 1}).a}]})
export class C {}

OXC (main and #504 tip)

inputs:{a:[2,"a","a",(v) =>{value:v}.value]}
// setClassMetadata
args:[{transform:(v) =>{value:v}.value}]
i0.ɵɵProvidersFeature([{provide:"T",useFactory:() =>{a:1}.a}])

ngtsc 22.1.7

inputs: { a: [2, "a", "a", (v) => ({ value: v }).value] }
i0.ɵɵProvidersFeature([{ provide: 'T', useFactory: () => ({ a: 1 }).a }])

Where

crates/oxc_angular_compiler/src/output/emitter.rs (main ~L742 and ~L766):

  • OutputExpression::Parenthesized prints only its inner expression, without the parentheses.
  • The ArrowFunction arm adds (...) only when the whole body is an object literal (LiteralMap, after unwrapping one Parenthesized). A body like ReadProp(Parenthesized(LiteralMap)) starts with { but gets no parentheses.

Related: #43 (closed) fixed the plain () => ({...}) case. Open PR #498 extends the same check to raw-source objects but still only checks the whole body, so it doesn't fix this.

On main?

Yes.

Direction

Add parentheses when the leftmost token of the body would be {: walk receivers of member access, calls, binary operators and so on. Or have Parenthesized keep its parentheses whenever the inner expression is an object literal.

Lenguaje dominante
Rust
Estrellas
232
Forks
21
Merge medio
1 d 18 h
PR fusionados (30 d)
59

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.