@@ -532,7 +532,7 @@ namespace ts {
532
532
}
533
533
534
534
// Because of module/namespace merging, a module's exports are in scope,
535
- // yet we never want to treat an export specifier as putting a member in scope.
535
+ // yet we never want to treat an export specifier as putting a member in scope.
536
536
// Therefore, if the name we find is purely an export specifier, it is not actually considered in scope.
537
537
// Two things to note about this:
538
538
// 1. We have to check this without calling getSymbol. The problem with calling getSymbol
@@ -3197,7 +3197,7 @@ namespace ts {
3197
3197
case SyntaxKind.BooleanKeyword:
3198
3198
case SyntaxKind.SymbolKeyword:
3199
3199
case SyntaxKind.VoidKeyword:
3200
- case SyntaxKind.StringLiteral :
3200
+ case SyntaxKind.StringLiteralType :
3201
3201
return true;
3202
3202
case SyntaxKind.ArrayType:
3203
3203
return isIndependentType((<ArrayTypeNode>node).elementType);
@@ -3858,7 +3858,7 @@ namespace ts {
3858
3858
paramSymbol = resolvedSymbol;
3859
3859
}
3860
3860
parameters.push(paramSymbol);
3861
- if (param.type && param.type.kind === SyntaxKind.StringLiteral ) {
3861
+ if (param.type && param.type.kind === SyntaxKind.StringLiteralType ) {
3862
3862
hasStringLiterals = true;
3863
3863
}
3864
3864
@@ -4527,8 +4527,7 @@ namespace ts {
4527
4527
return links.resolvedType;
4528
4528
}
4529
4529
4530
- function getStringLiteralType(node: StringLiteral): StringLiteralType {
4531
- const text = node.text;
4530
+ function getStringLiteralType(text: string): StringLiteralType {
4532
4531
if (hasProperty(stringLiteralTypes, text)) {
4533
4532
return stringLiteralTypes[text];
4534
4533
}
@@ -4538,10 +4537,10 @@ namespace ts {
4538
4537
return type;
4539
4538
}
4540
4539
4541
- function getTypeFromStringLiteral(node: StringLiteral): Type {
4540
+ function getTypeFromStringLiteral(node: StringLiteral | StringLiteralTypeNode ): Type {
4542
4541
const links = getNodeLinks(node);
4543
4542
if (!links.resolvedType) {
4544
- links.resolvedType = getStringLiteralType(node);
4543
+ links.resolvedType = getStringLiteralType(node.text );
4545
4544
}
4546
4545
return links.resolvedType;
4547
4546
}
@@ -4583,8 +4582,8 @@ namespace ts {
4583
4582
return voidType;
4584
4583
case SyntaxKind.ThisType:
4585
4584
return getTypeFromThisTypeNode(node);
4586
- case SyntaxKind.StringLiteral :
4587
- return getTypeFromStringLiteral(<StringLiteral >node);
4585
+ case SyntaxKind.StringLiteralType :
4586
+ return getTypeFromStringLiteral(<StringLiteralTypeNode >node);
4588
4587
case SyntaxKind.TypeReference:
4589
4588
return getTypeFromTypeReference(<TypeReferenceNode>node);
4590
4589
case SyntaxKind.TypePredicate:
@@ -8791,7 +8790,7 @@ namespace ts {
8791
8790
// for the argument. In that case, we should check the argument.
8792
8791
if (argType === undefined) {
8793
8792
argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors
8794
- ? getStringLiteralType(<StringLiteral>arg)
8793
+ ? getStringLiteralType(( <StringLiteral>arg).text )
8795
8794
: checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
8796
8795
}
8797
8796
@@ -8986,7 +8985,7 @@ namespace ts {
8986
8985
case SyntaxKind.Identifier:
8987
8986
case SyntaxKind.NumericLiteral:
8988
8987
case SyntaxKind.StringLiteral:
8989
- return getStringLiteralType(<StringLiteral >element.name);
8988
+ return getStringLiteralType((<Identifier | LiteralExpression >element.name).text );
8990
8989
8991
8990
case SyntaxKind.ComputedPropertyName:
8992
8991
const nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
@@ -10608,7 +10607,8 @@ namespace ts {
10608
10607
function checkStringLiteralExpression(node: StringLiteral): Type {
10609
10608
const contextualType = getContextualType(node);
10610
10609
if (contextualType && contextualTypeIsStringLiteralType(contextualType)) {
10611
- return getStringLiteralType(node);
10610
+ // TODO (drosen): Consider using getTypeFromStringLiteral instead
10611
+ return getStringLiteralType(node.text);
10612
10612
}
10613
10613
10614
10614
return stringType;
@@ -11442,7 +11442,7 @@ namespace ts {
11442
11442
// we can get here in two cases
11443
11443
// 1. mixed static and instance class members
11444
11444
// 2. something with the same name was defined before the set of overloads that prevents them from merging
11445
- // here we'll report error only for the first case since for second we should already report error in binder
11445
+ // here we'll report error only for the first case since for second we should already report error in binder
11446
11446
if (reportError) {
11447
11447
const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
11448
11448
error(errorNode, diagnostic);
0 commit comments