From 8087206078f07f99f4e70f257661575e505ac293 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 11:09:25 -0700 Subject: [PATCH] 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'. --- src/compiler/checker.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8acecf57e50..69862a93d2f 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[] = [];