Skip to content

Commit 8087206

Browse files
committed
Explain boolean exception in getIndexedAccessType
Booleans are not treated like other unions in order to skip straight to error reporting so that the error is reported with 'boolean' instead of 'true'.
1 parent 197040d commit 8087206

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7693,6 +7693,8 @@ namespace ts {
76937693
return type;
76947694
}
76957695
// In the following we resolve T[K] to the type of the property in T selected by K.
7696+
// We treat boolean as different from other unions to improve errors;
7697+
// skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'.
76967698
const apparentObjectType = getApparentType(objectType);
76977699
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) {
76987700
const propTypes: Type[] = [];

0 commit comments

Comments
 (0)