Add elaboration & quickfix for async-able arrow function (#36342)

This commit is contained in:
Wesley Wigham
2020-02-21 15:51:02 -08:00
committed by GitHub
parent 6b645f582b
commit ebca423a6e
7 changed files with 171 additions and 0 deletions

View File

@@ -14153,6 +14153,17 @@ namespace ts {
Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature,
));
}
if ((getFunctionFlags(node) & FunctionFlags.Async) === 0
// exclude cases where source itself is promisy - this way we don't make a suggestion when relating
// an IPromise and a Promise that are slightly different
&& !getTypeOfPropertyOfType(sourceReturn, "then" as __String)
&& checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, /*errorNode*/ undefined)
) {
addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], createDiagnosticForNode(
node,
Diagnostics.Did_you_mean_to_mark_this_function_as_async
));
}
return true;
}
}