diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8acecf57e5..69862a93d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7693,6 +7693,8 @@ namespace ts { return type; } // In the following we resolve T[K] to the type of the property in T selected by K. + // We treat boolean as different from other unions to improve errors; + // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. const apparentObjectType = getApparentType(objectType); if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) { const propTypes: Type[] = [];