Treat 'yield;' as 'yield undefined;' (#22297)

* Treat 'yield;' as 'yield undefined;'

* Use undefinedWideningType
This commit is contained in:
Andy
2018-03-08 15:41:04 -08:00
committed by GitHub
parent 28e8c4f3b8
commit e48bcd60ba
11 changed files with 121 additions and 25 deletions

View File

@@ -18525,9 +18525,7 @@ namespace ts {
const aggregatedTypes: Type[] = [];
const isAsync = (getFunctionFlags(func) & FunctionFlags.Async) !== 0;
forEachYieldExpression(<Block>func.body, yieldExpression => {
if (yieldExpression.expression) { // TODO: GH#22297
pushIfUnique(aggregatedTypes, getYieldedTypeOfYieldExpression(yieldExpression, isAsync, checkMode));
}
pushIfUnique(aggregatedTypes, getYieldedTypeOfYieldExpression(yieldExpression, isAsync, checkMode));
});
return aggregatedTypes;
}
@@ -19520,8 +19518,6 @@ namespace ts {
}
}
if (!node.expression) return anyType; // TODO: GH#22297
const isAsync = (functionFlags & FunctionFlags.Async) !== 0;
const yieldedType = getYieldedTypeOfYieldExpression(node, isAsync);
// There is no point in doing an assignability check if the function