MCPcopy Index your code
hub / github.com/nodejs/node / createLazyCaseClauseDiagnostics

Function createLazyCaseClauseDiagnostics

test/fixtures/snapshot/typescript.js:83719–83736  ·  view source on GitHub ↗
(clause)

Source from the content-addressed store, hash-verified

83717 error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
83718 }
83719 function createLazyCaseClauseDiagnostics(clause) {
83720 return function () {
83721 // TypeScript 1.0 spec (April 2014): 5.9
83722 // In a 'switch' statement, each 'case' expression must be of a type that is comparable
83723 // to or from the type of the 'switch' expression.
83724 var caseType = checkExpression(clause.expression);
83725 var caseIsLiteral = isLiteralType(caseType);
83726 var comparedExpressionType = expressionType;
83727 if (!caseIsLiteral || !expressionIsLiteral) {
83728 caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
83729 comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
83730 }
83731 if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
83732 // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
83733 checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
83734 }
83735 };
83736 }
83737 });
83738 if (node.caseBlock.locals) {
83739 registerForUnusedIdentifiersCheck(node.caseBlock);

Callers 1

checkSwitchStatementFunction · 0.85

Calls 5

isLiteralTypeFunction · 0.85
getBaseTypeOfLiteralTypeFunction · 0.85
checkTypeComparableToFunction · 0.85
checkExpressionFunction · 0.70

Tested by

no test coverage detected