TypeScript Version: 2.8.0-dev.20180302
Search Terms: generator, yield, strictNullChecks, typechecking
Code
function* myGenerator(): IterableIterator<number> {
yield;
yield 2;
}
for (let n of myGenerator()) {
let number: number = n;
console.log(number);
}
tsconfig.json:
{
"compilerOptions": {
"target":"es6",
"strictNullChecks": true,
}
}
Expected behavior:
I would expect yield; (without expression) to be forbidden if the generator return type (IterableIterator<number>) doesn't allow undefined.
Actual behavior:
This compiles fine, prints 'undefined', '2' (we're essentially allowing undefined to be assigned to non-nullable number).
Playground Link: link
TypeScript Version: 2.8.0-dev.20180302
Search Terms: generator, yield, strictNullChecks, typechecking
Code
tsconfig.json:
Expected behavior:
I would expect
yield;(without expression) to be forbidden if the generator return type (IterableIterator<number>) doesn't allow undefined.Actual behavior:
This compiles fine, prints 'undefined', '2' (we're essentially allowing
undefinedto be assigned to non-nullablenumber).Playground Link: link