Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#510 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
angular, rust
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
232
フォーク
21
平均マージ
1日 18時間
マージ済み PR(30日)
59

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

voidzero-dev/oxc-angular-compiler のほかの issue

voidzero-dev/oxc-angular-compiler の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。