Only add "Did you forget await" for function args when the parameter type is not promise-like

This commit is contained in:
Andrew Branch 2019-07-08 16:32:53 -07:00
parent 64501996cc
commit bdd8a3e878
No known key found for this signature in database
GPG Key ID: 22CCA4B120C427D2

View File

@ -21453,6 +21453,10 @@ namespace ts {
function maybeAddMissingAwaitInfo(errorNode: Node | undefined, source: Type, target: Type) {
if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
// Bail if target is Promise-like---something else is wrong
if (getAwaitedTypeOfPromise(target)) {
return;
}
const awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
addRelatedInfo(errorOutputContainer.errors[0], createDiagnosticForNode(errorNode, Diagnostics.Did_you_forget_to_use_await));