Closed
Description
TypeScript Version: 2.6.1 - 2.7.0-dev.20171128
Code:
// index.ts
function* testGenerator() {
if (Math.random() > 0.5) {
return;
}
yield 'hello';
}
/* tsconfig.json
{
"files": ["index.ts"],
"compilerOptions": {
"lib": ["esnext"], "target": "ESNEXT", "module": "es2015",
"strictNullChecks": true,
"noImplicitReturns": true
}
}
*/
Expected behavior:
No errors due to the generator's early return
, regardless of whether strictNullChecks
is true or false.
Actual behavior:
- No errors when
strictNullChecks
is true - The following error when
strictNullChecks
is false:
index.ts(3,9): error TS7030: Not all code paths return a value.