引起错误的TypeScript代码:
test(){
const a = () => ({ a , b = 2 } = {}): number => 11;
}
![](https://img.haomeiwen.com/i2085791/1fa3022a0d31e163.png)
该编译错误的解决方法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;
}
网友评论