@@ -532,7 +532,7 @@ namespace ts {
532532 }
533533
534534 // 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.
536536 // Therefore, if the name we find is purely an export specifier, it is not actually considered in scope.
537537 // Two things to note about this:
538538 // 1. We have to check this without calling getSymbol. The problem with calling getSymbol
@@ -3197,7 +3197,7 @@ namespace ts {
31973197 case SyntaxKind.BooleanKeyword:
31983198 case SyntaxKind.SymbolKeyword:
31993199 case SyntaxKind.VoidKeyword:
3200- case SyntaxKind.StringLiteral :
3200+ case SyntaxKind.StringLiteralType :
32013201 return true;
32023202 case SyntaxKind.ArrayType:
32033203 return isIndependentType((<ArrayTypeNode>node).elementType);
@@ -3858,7 +3858,7 @@ namespace ts {
38583858 paramSymbol = resolvedSymbol;
38593859 }
38603860 parameters.push(paramSymbol);
3861- if (param.type && param.type.kind === SyntaxKind.StringLiteral ) {
3861+ if (param.type && param.type.kind === SyntaxKind.StringLiteralType ) {
38623862 hasStringLiterals = true;
38633863 }
38643864
@@ -4527,8 +4527,7 @@ namespace ts {
45274527 return links.resolvedType;
45284528 }
45294529
4530- function getStringLiteralType(node: StringLiteral): StringLiteralType {
4531- const text = node.text;
4530+ function getStringLiteralType(text: string): StringLiteralType {
45324531 if (hasProperty(stringLiteralTypes, text)) {
45334532 return stringLiteralTypes[text];
45344533 }
@@ -4538,10 +4537,10 @@ namespace ts {
45384537 return type;
45394538 }
45404539
4541- function getTypeFromStringLiteral(node: StringLiteral): Type {
4540+ function getTypeFromStringLiteral(node: StringLiteral | StringLiteralTypeNode ): Type {
45424541 const links = getNodeLinks(node);
45434542 if (!links.resolvedType) {
4544- links.resolvedType = getStringLiteralType(node);
4543+ links.resolvedType = getStringLiteralType(node.text );
45454544 }
45464545 return links.resolvedType;
45474546 }
@@ -4583,8 +4582,8 @@ namespace ts {
45834582 return voidType;
45844583 case SyntaxKind.ThisType:
45854584 return getTypeFromThisTypeNode(node);
4586- case SyntaxKind.StringLiteral :
4587- return getTypeFromStringLiteral(<StringLiteral >node);
4585+ case SyntaxKind.StringLiteralType :
4586+ return getTypeFromStringLiteral(<StringLiteralTypeNode >node);
45884587 case SyntaxKind.TypeReference:
45894588 return getTypeFromTypeReference(<TypeReferenceNode>node);
45904589 case SyntaxKind.TypePredicate:
@@ -8791,7 +8790,7 @@ namespace ts {
87918790 // for the argument. In that case, we should check the argument.
87928791 if (argType === undefined) {
87938792 argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors
8794- ? getStringLiteralType(<StringLiteral>arg)
8793+ ? getStringLiteralType(( <StringLiteral>arg).text )
87958794 : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
87968795 }
87978796
@@ -8986,7 +8985,7 @@ namespace ts {
89868985 case SyntaxKind.Identifier:
89878986 case SyntaxKind.NumericLiteral:
89888987 case SyntaxKind.StringLiteral:
8989- return getStringLiteralType(<StringLiteral >element.name);
8988+ return getStringLiteralType((<Identifier | LiteralExpression >element.name).text );
89908989
89918990 case SyntaxKind.ComputedPropertyName:
89928991 const nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
@@ -10608,7 +10607,8 @@ namespace ts {
1060810607 function checkStringLiteralExpression(node: StringLiteral): Type {
1060910608 const contextualType = getContextualType(node);
1061010609 if (contextualType && contextualTypeIsStringLiteralType(contextualType)) {
10611- return getStringLiteralType(node);
10610+ // TODO (drosen): Consider using getTypeFromStringLiteral instead
10611+ return getStringLiteralType(node.text);
1061210612 }
1061310613
1061410614 return stringType;
@@ -11442,7 +11442,7 @@ namespace ts {
1144211442 // we can get here in two cases
1144311443 // 1. mixed static and instance class members
1144411444 // 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
1144611446 if (reportError) {
1144711447 const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
1144811448 error(errorNode, diagnostic);
0 commit comments