node es6 变相实现支持ts的剩余参数实现方式

//.ts method
assign(to: any, options?: AssignOptions, ...forms: any[]){}
//tsc 编译为es6的js
assign(to, options, ...forms) { }

如上的代码在node run起来之后报错。语法解析错误。不支持...forms

实现方式:使用函数的重载方式

 assign(to: any, options?: AssignOptions, ...forms: any[]);
 assign() { //your code }
//tsc 编译后的es6代码
assign() { //your code }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 1970-01-01
  • 2022-12-23
  • 2021-06-22
猜你喜欢
  • 2021-11-23
  • 2021-09-23
  • 2021-05-26
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
相关资源
相似解决方案