mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 22:39:59 -05:00
Contextually type return statement in async function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user