fix(emit): arrow functions in metadata lose default parameter values and `async`
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust, typescript
- 领域
- compilers
调研方向
Start in crates/oxc_angular_compiler/src/output/oxc_converter.rs, especially convert_arrow_function_expression, and inspect ArrowFunctionExpr in output/ast.rs; the issue notes that the function-expression path may have the same problem. Reproduce with the TypeScript examples and compare emitted arrows against the expected output shown. Done means defaults and async are preserved or the documented raw-source fallback is used.
由索引模型根据 Issue 内容生成。
描述
Arrows copied from decorator metadata into the output lose parameter defaults and the async keyword. This changes runtime behavior: an async factory returns a value instead of a Promise, and a default value is no longer applied.
Repro
import {Component, Directive, Input} from '@angular/core';
@Directive({selector: '[d]'})
export class D {
@Input({transform: (v: string = 'a') => v.length}) a = 0;
@Input({transform: async (v: any) => 1}) b: any;
}
@Component({selector: 'c', template: '', providers: [{provide: 'T', useFactory: async (x: number = 1) => x}]})
export class C {}
OXC (main and #504 tip)
inputs:{a:[2,"a","a",(v) =>v.length],b:[2,"b","b",(v) =>1]}
// setClassMetadata
{a:[{type:Input,args:[{transform:(v) =>v.length}]}],b:[{type:Input,args:[{transform:(v) =>1}]}]}
i0.ɵɵProvidersFeature([{provide:"T",useFactory:(x) =>x}])
ngtsc 22.1.7
inputs: { a: [2, "a", "a", (v = 'a') => v.length], b: [2, "b", "b", async (v) => 1] }
{ a: [{ type: Input, args: [{ transform: (v = 'a') => v.length }] }], b: [{ type: Input, args: [{ transform: async (v) => 1 }] }] }
i0.ɵɵProvidersFeature([{ provide: 'T', useFactory: async (x = 1) => x }])
The .d.ts is already correct on the stack (ngAcceptInputType_a: string, ngAcceptInputType_b: any).
Where
crates/oxc_angular_compiler/src/output/oxc_converter.rs (main), convert_arrow_function_expression:
- It reads only
param.pattern(aBindingIdentifier) and ignores the parameter's default value. - It ignores
arrow.r#async.
ArrowFunctionExpr (output/ast.rs) has no field for either. The function-expression path is worth checking for the same issue.
On main?
Yes.
Direction
Add async and default values to the output AST, or fall back to raw source (types stripped) when the arrow uses either, as is already done for destructured params.
- 主要语言
- Rust
- 星标
- 232
- 派生
- 21
- 平均合并
- 1 天 18 小时
- 30 天内合并 PR
- 59
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/oxc-angular-compiler 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
voidzero-dev/oxc-angular-compiler#563 ·
维护者通常 1 天内回复
-
e2e compare: setClassMetadata extraction regex never matches (ɵɵ vs ɵ) — classMetadataDiffs is dead code可能已有人在做 @Brooooooklyn 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 38/100
voidzero-dev/oxc-angular-compiler#561 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 68/100
voidzero-dev/oxc-angular-compiler#506 ·
维护者通常 1 天内回复
-
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 天内回复
查看 voidzero-dev/oxc-angular-compiler 的全部 Issue
相似的 Issue
-
mxl-compile: пример заполнения ячеек отклоняется Unica可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1-3 小时 新手友好度 91/100
IngvarConsulting/unica#1301 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 1/5 1 小时以内 新手友好度 75/100
ajeetraina/awesome-docker-sbx#220 ·
-
`helios / deploy`: switch zone wait in `deploy.sh` has almost no headroom over healthy startup times可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭Test Flake
难度 2/5 1-3 小时 新手友好度 74/100
oxidecomputer/omicron#11453 ·
维护者通常 1 天内回复