Skip to content

Commit

Permalink
Fixed a false positive "await has no effect on the type" diagnostic w…
Browse files Browse the repository at this point in the history
…ith mixed generic union (#50833)
  • Loading branch information
Andarist committed Oct 18, 2022
1 parent 1f8959f commit 85d405a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts
@@ -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([]);

0 comments on commit 85d405a

Please sign in to comment.