我遇到了一个错误
Type must have a '[Symbol.iterator]()' method that returns an iterator.
它希望在分界线上:
class Test {
private async do() {
const done = [...(await this.test())]; // Here's the error
}
private async *test(): AsyncIterableIterator<string> {
return;
}
}
我在 TypeScript GitHub 存储库中发现了一些问题,但似乎都没有帮助。他们都建议向 lib
添加新条目。我使用的是 es6
目标,并添加了 esnext
,dom
和 es2018
。这对错误没有任何影响。
我是否错过了更多的 lib
条目(我怀疑我使用的是包含所有内容的 catchall 条目)或者我使用的代码是无效的?