Skip to content

Commit 6168d6f

Browse files
author
Andy
authored
Inline checkLiteralExpression (#17720)
1 parent 9daa70c commit 6168d6f

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17850,21 +17850,6 @@ namespace ts {
1785017850
return getBestChoiceType(type1, type2);
1785117851
}
1785217852

17853-
function checkLiteralExpression(node: LiteralExpression | Token<SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword>): Type {
17854-
switch (node.kind) {
17855-
case SyntaxKind.NoSubstitutionTemplateLiteral:
17856-
case SyntaxKind.StringLiteral:
17857-
return getFreshTypeOfLiteralType(getLiteralType(node.text));
17858-
case SyntaxKind.NumericLiteral:
17859-
checkGrammarNumericLiteral(<NumericLiteral>node);
17860-
return getFreshTypeOfLiteralType(getLiteralType(+node.text));
17861-
case SyntaxKind.TrueKeyword:
17862-
return trueType;
17863-
case SyntaxKind.FalseKeyword:
17864-
return falseType;
17865-
}
17866-
}
17867-
1786817853
function checkTemplateExpression(node: TemplateExpression): Type {
1786917854
// We just want to check each expressions, but we are unconcerned with
1787017855
// the type of each expression, as any value may be coerced into a string.
@@ -18077,10 +18062,14 @@ namespace ts {
1807718062
return nullWideningType;
1807818063
case SyntaxKind.NoSubstitutionTemplateLiteral:
1807918064
case SyntaxKind.StringLiteral:
18065+
return getFreshTypeOfLiteralType(getLiteralType((node as LiteralExpression).text));
1808018066
case SyntaxKind.NumericLiteral:
18067+
checkGrammarNumericLiteral(node as NumericLiteral);
18068+
return getFreshTypeOfLiteralType(getLiteralType(+(node as NumericLiteral).text));
1808118069
case SyntaxKind.TrueKeyword:
18070+
return trueType;
1808218071
case SyntaxKind.FalseKeyword:
18083-
return checkLiteralExpression(node as LiteralExpression);
18072+
return falseType;
1808418073
case SyntaxKind.TemplateExpression:
1808518074
return checkTemplateExpression(<TemplateExpression>node);
1808618075
case SyntaxKind.RegularExpressionLiteral:

0 commit comments

Comments
 (0)