@@ -13594,10 +13594,10 @@ namespace ts {
13594
13594
// }
13595
13595
//
13596
13596
// The implied type of the first clause number | string.
13597
- // The implied type of the second clause is string ( but this doesn't get used) .
13597
+ // The implied type of the second clause is never, but this does not get just because it includes a default case .
13598
13598
// The implied type of the third clause is boolean (number has already be caught).
13599
13599
if (!(hasDefaultClause || (type.flags & TypeFlags.Union))) {
13600
- let impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(text => typeofTypesByName.get(text) || neverType)), switchFacts);
13600
+ let impliedType = getTypeWithFacts(getUnionType((<string[]> clauseWitnesses) .map(text => typeofTypesByName.get(text) || neverType)), switchFacts);
13601
13601
if (impliedType.flags & TypeFlags.Union) {
13602
13602
impliedType = getAssignmentReducedType(impliedType as UnionType, getBaseConstraintOfType(type) || type);
13603
13603
}
@@ -19027,30 +19027,35 @@ namespace ts {
19027
19027
if (hasDefault) {
19028
19028
// Value is not equal to any types after the active clause.
19029
19029
for (let i = end; i < witnesses.length; i++) {
19030
- facts |= typeofNEFacts.get(witnesses[i]) || TypeFacts.TypeofNEHostObject;
19030
+ const witness = witnesses[i];
19031
+ facts |= (witness && typeofNEFacts.get(witness)) || TypeFacts.TypeofNEHostObject;
19031
19032
}
19032
19033
// Remove inequalities for types that appear in the
19033
19034
// active clause because they appear before other
19034
19035
// types collected so far.
19035
19036
for (let i = start; i < end; i++) {
19036
- facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
19037
+ const witness = witnesses[i];
19038
+ facts &= ~((witness && typeofNEFacts.get(witness)) || 0);
19037
19039
}
19038
19040
// Add inequalities for types before the active clause unconditionally.
19039
19041
for (let i = 0; i < start; i++) {
19040
- facts |= typeofNEFacts.get(witnesses[i]) || TypeFacts.TypeofNEHostObject;
19042
+ const witness = witnesses[i];
19043
+ facts |= (witness && typeofNEFacts.get(witness)) || TypeFacts.TypeofNEHostObject;
19041
19044
}
19042
19045
}
19043
19046
// When in an active clause without default the set of
19044
19047
// equalities is finite.
19045
19048
else {
19046
19049
// Add equalities for all types in the active clause.
19047
19050
for (let i = start; i < end; i++) {
19048
- facts |= typeofEQFacts.get(witnesses[i]) || TypeFacts.TypeofEQHostObject;
19051
+ const witness = witnesses[i];
19052
+ facts |= (witness && typeofEQFacts.get(witness)) || TypeFacts.TypeofEQHostObject;
19049
19053
}
19050
19054
// Remove equalities for types that appear before the
19051
19055
// active clause.
19052
19056
for (let i = 0; i < start; i++) {
19053
- facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
19057
+ const witness = witnesses[i];
19058
+ facts &= ~((witness && typeofEQFacts.get(witness)) || 0);
19054
19059
}
19055
19060
}
19056
19061
return facts;
0 commit comments