Fixed a false positive "await has no effect on the type" diagnostic with mixed generic union (#50833)

This commit is contained in:
Mateusz Burzyński
2022-10-18 23:10:03 +02:00
committed by GitHub
parent 1f8959f5dc
commit 85d405a1d7
2 changed files with 13 additions and 1 deletions

View File

@@ -37104,7 +37104,7 @@ namespace ts {
// We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
// or is promise-like.
if (baseConstraint ?
baseConstraint.flags & TypeFlags.AnyOrUnknown || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
baseConstraint.flags & TypeFlags.AnyOrUnknown || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
maybeTypeOfKind(type, TypeFlags.TypeVariable)) {
return true;
}

View File

@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
// @target: esnext
//// async function fn1(a: Promise<void> | void) {
//// await a;
//// }
////
//// async function fn2<T extends Promise<void> | void>(a: T) {
//// await a;
//// }
verify.getSuggestionDiagnostics([]);