Contextually type return statement in async function

This commit is contained in:
Andy Hanson
2016-06-09 10:55:45 -07:00
parent 75b82938f5
commit 7a2ef428cd
5 changed files with 91 additions and 0 deletions

View File

@@ -8756,6 +8756,16 @@ namespace ts {
function getContextualTypeForReturnExpression(node: Expression): Type {
const func = getContainingFunction(node);
if (isAsyncFunctionLike(func)) {
const contextualReturnType = getContextualReturnType(func);
if (contextualReturnType) {
return getPromisedType(contextualReturnType);
}
return undefined;
}
if (func && !func.asteriskToken) {
return getContextualReturnType(func);
}