美文网首页
“Initializer provides no value f

“Initializer provides no value f

作者: 华山令狐冲 | 来源:发表于2021-02-15 10:31 被阅读0次

引起错误的TypeScript代码:

test(){
    const a = () => ({ a , b = 2 } = {}): number => 11;
  }

该编译错误的解决方法1

test(){
    const a = () => ({ a , b = 2 }:any = {}): number => 11;
  }

解法2

test(){
    const a = () => ({ a = 1, b = 2 } = {}): number => 11;
  }

解法3

 test(){
    const fun = () => ({ a , b } = { a: 1, b: 2}): number => 11;
  }

参考:https://stackoverflow.com/questions/57527710/how-to-fix-initializer-provides-no-value-for-this-binding-element-and-the-bindi

相关文章

网友评论

      本文标题:“Initializer provides no value f

      本文链接:https://www.haomeiwen.com/subject/yitjbktx.html