@@ -4531,8 +4531,7 @@ namespace ts {
4531
4531
return links.resolvedType;
4532
4532
}
4533
4533
4534
- function getStringLiteralType(node: StringLiteral | StringLiteralTypeNode): StringLiteralType {
4535
- const text = node.text;
4534
+ function getStringLiteralType(text: string): StringLiteralType {
4536
4535
if (hasProperty(stringLiteralTypes, text)) {
4537
4536
return stringLiteralTypes[text];
4538
4537
}
@@ -4545,7 +4544,7 @@ namespace ts {
4545
4544
function getTypeFromStringLiteral(node: StringLiteral | StringLiteralTypeNode): Type {
4546
4545
const links = getNodeLinks(node);
4547
4546
if (!links.resolvedType) {
4548
- links.resolvedType = getStringLiteralType(node);
4547
+ links.resolvedType = getStringLiteralType(node.text );
4549
4548
}
4550
4549
return links.resolvedType;
4551
4550
}
@@ -8747,7 +8746,7 @@ namespace ts {
8747
8746
// for the argument. In that case, we should check the argument.
8748
8747
if (argType === undefined) {
8749
8748
argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors
8750
- ? getStringLiteralType(<StringLiteral>arg)
8749
+ ? getStringLiteralType(( <StringLiteral>arg).text )
8751
8750
: checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
8752
8751
}
8753
8752
@@ -8942,7 +8941,7 @@ namespace ts {
8942
8941
case SyntaxKind.Identifier:
8943
8942
case SyntaxKind.NumericLiteral:
8944
8943
case SyntaxKind.StringLiteral:
8945
- return getStringLiteralType(<StringLiteral >element.name);
8944
+ return getStringLiteralType((<Identifier | LiteralExpression >element.name).text );
8946
8945
8947
8946
case SyntaxKind.ComputedPropertyName:
8948
8947
const nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
@@ -10564,7 +10563,8 @@ namespace ts {
10564
10563
function checkStringLiteralExpression(node: StringLiteral): Type {
10565
10564
const contextualType = getContextualType(node);
10566
10565
if (contextualType && contextualTypeIsStringLiteralType(contextualType)) {
10567
- return getStringLiteralType(node);
10566
+ // TODO (drosen): Consider using getTypeFromStringLiteral instead
10567
+ return getStringLiteralType(node.text);
10568
10568
}
10569
10569
10570
10570
return stringType;
0 commit comments