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:
parent
197040d3fd
commit
8087206078
1 changed files with 2 additions and 0 deletions
|
@ -7693,6 +7693,8 @@ namespace ts {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
// In the following we resolve T[K] to the type of the property in T selected by K.
|
// 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);
|
const apparentObjectType = getApparentType(objectType);
|
||||||
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) {
|
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) {
|
||||||
const propTypes: Type[] = [];
|
const propTypes: Type[] = [];
|
||||||
|
|
Loading…
Reference in a new issue