mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #9003 from Microsoft/caseUndefinedAndNull
Allow case comparison to undefined and null in strict null checking mode
This commit is contained in:
@@ -15110,7 +15110,7 @@ namespace ts {
|
||||
// In a 'switch' statement, each 'case' expression must be of a type that is comparable
|
||||
// to or from the type of the 'switch' expression.
|
||||
const caseType = checkExpression(caseClause.expression);
|
||||
if (!isTypeComparableTo(expressionType, caseType)) {
|
||||
if (!isTypeEqualityComparableTo(expressionType, caseType)) {
|
||||
// expressionType is not comparable to caseType, try the reversed check and report errors if it fails
|
||||
checkTypeComparableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user