fix(compiler-cli): create LiteralLikeNode for String and Number literal (#27536)
Typescript 3.2 introduced BigInt type, and consequently the implementation for checkExpressionWorker() in checkers.ts is refactored. For NumberLiteral and StringLiteral types, 'text' filed must be present in the Node type, therefore they must be LiteralLikeNode instead of Node. PR Close #27536
This commit is contained in:

committed by
Miško Hevery

parent
17e702bf8b
commit
2c9b6c0c1f
@ -718,13 +718,20 @@ function getBuiltinTypeFromTs(kind: BuiltinType, context: TypeContext): ts.Type
|
||||
checker.getTypeAtLocation(setParents(<ts.Node>{kind: ts.SyntaxKind.NullKeyword}, node));
|
||||
break;
|
||||
case BuiltinType.Number:
|
||||
const numeric = <ts.Node>{kind: ts.SyntaxKind.NumericLiteral};
|
||||
const numeric = <ts.LiteralLikeNode>{
|
||||
kind: ts.SyntaxKind.NumericLiteral,
|
||||
text: node.getText(),
|
||||
};
|
||||
setParents(<any>{kind: ts.SyntaxKind.ExpressionStatement, expression: numeric}, node);
|
||||
type = checker.getTypeAtLocation(numeric);
|
||||
break;
|
||||
case BuiltinType.String:
|
||||
type = checker.getTypeAtLocation(
|
||||
setParents(<ts.Node>{kind: ts.SyntaxKind.NoSubstitutionTemplateLiteral}, node));
|
||||
type = checker.getTypeAtLocation(setParents(
|
||||
<ts.LiteralLikeNode>{
|
||||
kind: ts.SyntaxKind.NoSubstitutionTemplateLiteral,
|
||||
text: node.getText(),
|
||||
},
|
||||
node));
|
||||
break;
|
||||
case BuiltinType.Undefined:
|
||||
type = checker.getTypeAtLocation(setParents(
|
||||
|
Reference in New Issue
Block a user