diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 94e891ea255a9..ee02a3532eb3a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37104,7 +37104,7 @@ namespace ts { // We only need `Awaited` 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; } diff --git a/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts b/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts new file mode 100644 index 0000000000000..605e5b97481aa --- /dev/null +++ b/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts @@ -0,0 +1,12 @@ +/// + +// @target: esnext +//// async function fn1(a: Promise | void) { +//// await a; +//// } +//// +//// async function fn2 | void>(a: T) { +//// await a; +//// } + +verify.getSuggestionDiagnostics([]);