mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
getSwitchClauseTypes: exit early if getTypeOfSwitchClause is undefined (#16865)
This commit is contained in:
@@ -11066,8 +11066,14 @@ namespace ts {
|
||||
if (!links.switchTypes) {
|
||||
// If all case clauses specify expressions that have unit types, we return an array
|
||||
// of those unit types. Otherwise we return an empty array.
|
||||
const types = map(switchStatement.caseBlock.clauses, getTypeOfSwitchClause);
|
||||
links.switchTypes = !contains(types, undefined) ? types : emptyArray;
|
||||
links.switchTypes = [];
|
||||
for (const clause of switchStatement.caseBlock.clauses) {
|
||||
const type = getTypeOfSwitchClause(clause);
|
||||
if (type === undefined) {
|
||||
return links.switchTypes = emptyArray;
|
||||
}
|
||||
links.switchTypes.push(type);
|
||||
}
|
||||
}
|
||||
return links.switchTypes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user