fix(emit): `(v) => ({value: v}).value` is printed as invalid `(v) =>{value:v}.value`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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 内容生成。
描述
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::Parenthesizedprints only its inner expression, without the parentheses.- The
ArrowFunctionarm adds(...)only when the whole body is an object literal (LiteralMap, after unwrapping oneParenthesized). A body likeReadProp(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 天 16 小时
- 30 天内合并 PR
- 62
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/oxc-angular-compiler 的其他 Issue
-
bug
难度 4/5 3-5 天 新手友好度 68/100
voidzero-dev/oxc-angular-compiler#505 ·
维护者通常 1 天内回复
-
bug rust
难度 4/5 3-5 天 新手友好度 56/100
voidzero-dev/oxc-angular-compiler#313 ·
维护者通常 1 天内回复
-
Support useDefineForClassFields: false (Class Field Lowering)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
voidzero-dev/oxc-angular-compiler#73 · 11 条评论 ·
维护者通常 1 天内回复
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR runtime parity regressions (RouterLinkActive, Forms DI, Apollo DI) require app-level shims可能重新可做 @Brooooooklyn 于 218 天前认领,目前没有进行中的 PR。 未关闭
voidzero-dev/oxc-angular-compiler#61 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Angular 21.2.0 + @oxc-angular/vite 0.0.7 SSR: AngularNodeAppEngine is unusable (missing app-engine manifest)可能重新可做 @Brooooooklyn 于 218 天前认领,目前没有进行中的 PR。 未关闭
voidzero-dev/oxc-angular-compiler#60 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
antithesishq/bombadil#361 ·
维护者通常 1 天内回复
-
test(executor_l0): assert execute() TaskOutcome, not only bus events / 断言 execute() 返回的 TaskOutcome未关闭type:debt
难度 2/5 1-3 小时 新手友好度 62/100
skaiy/wild_agentos#425 ·
维护者通常 1 天内回复
-
Default-import note suggests `import * as process` for velt:process, which does not name the builtin未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug ticket
难度 2/5 1-3 小时 新手友好度 72/100
cratestack/cratestack#1154 ·
维护者通常 1 天内回复
-
status:needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复