Skip to content

Commit 85d405a

Browse files
authoredOct 18, 2022
Fixed a false positive "await has no effect on the type" diagnostic with mixed generic union (#50833)
1 parent 1f8959f commit 85d405a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37104,7 +37104,7 @@ namespace ts {
3710437104
// 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`,
3710537105
// or is promise-like.
3710637106
if (baseConstraint ?
37107-
baseConstraint.flags & TypeFlags.AnyOrUnknown || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
37107+
baseConstraint.flags & TypeFlags.AnyOrUnknown || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
3710837108
maybeTypeOfKind(type, TypeFlags.TypeVariable)) {
3710937109
return true;
3711037110
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @target: esnext
4+
//// async function fn1(a: Promise<void> | void) {
5+
//// await a;
6+
//// }
7+
////
8+
//// async function fn2<T extends Promise<void> | void>(a: T) {
9+
//// await a;
10+
//// }
11+
12+
verify.getSuggestionDiagnostics([]);

0 commit comments

Comments
 (0)