mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Always check index type validity for all types when an error node is present so we always issue an error (#26789)
* Always check index type validity for all types when an error node is present so we always issue an error * Change type a bit
This commit is contained in:
@@ -9380,13 +9380,24 @@ namespace ts {
|
||||
const apparentObjectType = getApparentType(objectType);
|
||||
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) {
|
||||
const propTypes: Type[] = [];
|
||||
let wasMissingProp = false;
|
||||
for (const t of (<UnionType>indexType).types) {
|
||||
const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false, missingType);
|
||||
if (propType === missingType) {
|
||||
return missingType;
|
||||
if (!accessNode) {
|
||||
// If there's no error node, we can immeditely stop, since error reporting is off
|
||||
return missingType;
|
||||
}
|
||||
else {
|
||||
// Otherwise we set a flag and return at the end of the loop so we still mark all errors
|
||||
wasMissingProp = true;
|
||||
}
|
||||
}
|
||||
propTypes.push(propType);
|
||||
}
|
||||
if (wasMissingProp) {
|
||||
return missingType;
|
||||
}
|
||||
return getUnionType(propTypes);
|
||||
}
|
||||
return getPropertyTypeForIndexType(apparentObjectType, indexType, accessNode, /*cacheSymbol*/ true, missingType);
|
||||
|
||||
Reference in New Issue
Block a user