错误TS2339:属性’next’在类型上不存在
下面是我最接近的代码示例.
export default class GeneratorClass { constructor() { this.generator(10); this.generator.next(); } *generator(count:number): Iterable<number | undefined> { while(true) yield count++; } }
Here is the playground link for the same
export default class GeneratorClass { constructor() { const iterator = this.generator(10); iterator.next(); } *generator(count:number): IterableIterator<number> { while(true) yield count++; } }