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'.
This commit is contained in:
Nathan Shively-Sanders 2017-08-28 11:09:25 -07:00
parent 197040d3fd
commit 8087206078

View file

@ -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[] = [];