Reputation: 376
I updated typescript $ tsc -v Version 3.6.2
and tried the Generator example in the page below: https://devblogs.microsoft.com/typescript/announcing-typescript-3-6/
function* counter(): Generator<number, string, boolean> {
let i = 0;
while (true) {
if (yield i++) {
break;
}
}
return "done!";
}
var iter = counter();
var curr = iter.next()
while (!curr.done) {
console.log(curr.value);
curr = iter.next(curr.value === 5)
}
console.log(curr.value.toUpperCase());
error TS2318: Cannot find global type 'IterableIterator'.
gen2.ts:6:22 - error TS2304: Cannot find name 'Generator'.
6 function* counter(): Generator { ~~~~~~~~~
Found 2 errors.
Upvotes: 2
Views: 2318
Reputation: 175
In the tsconfig.json, update the "compilerOptions:target" value to ES2015 instead of ES5. Also, make sure to include your tsconfig.json in the CLI command like :
tsc -p .\tsconfig.json
Upvotes: 1
Reputation: 376
I needed to specify the lib in the command line: $ tsc --lib es6,dom gen2.ts
Upvotes: 0