Skip to content

[Bug]: Should not lower function default parameters when using `syntax: 'es2021' #284

@chenjiahan

Description

@chenjiahan

Version

Rslib 0.0.11

Details

  • Rslib config:
export default {
  lib: [
    {
      format: 'esm',
      syntax: 'es2021',
    },
  ],
  output: {
    target: 'node',
  },
};
  • Input:
export function foo(options: unknown = {}): void {
  console.log(options);
}
  • Current output:
function foo() {
    let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
    console.log(options);
}
export { foo };
  • Expected output:
function foo(options = {}) {
    console.log(options);
}
export { foo };

Reproduce link

I found this issue in some Rsbuild packages

Reproduce Steps

/

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions