我试过声明无济于事。这是我想做的简单事情:
this.scoreStack = [...Array(3).keys()];
显然,typescript 不支持这种解构。 我收到:
Symbol "keys" cannot be properly resolved, probably it is located in an inaccessible module
有没有一种方法可以定义 keys() 方法并克服这个限制?
最佳答案
Is there a way that I can define the keys() method and get over this limitation
你可以很容易地声明它:
declare global {
interface Array<T> {
keys():string[];
}
}
const x = [...Array(3).keys()];
关于javascript - 如何克服 typescript 的传播运算符限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37558890/