Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

fix(emit): arrow functions in metadata lose default parameter values and `async`

已关闭
#512 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Brooooooklyn 已经在做这个了。

开始于 2026年10月7日。

  • #555 来自 @Brooooooklyn —— 未关闭

评估

难度
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 内容生成。

描述

bug

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 (a BindingIdentifier) 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

voidzero-dev/oxc-angular-compiler 的其他 Issue

查看 voidzero-dev/oxc-angular-compiler 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。