mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Unescape string literal types starting with double underscore.
String literal types starting with double underscore are escaped in the parser and need to be unescaped before the type is given the string literal as its name.
This commit is contained in:
1 parent
3fb16f5930
commit
e25927da57
4 files changed
+24
-4
No files matched your search
@@ -5138,12 +5138,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getStringLiteralTypeForText(text: string): StringLiteralType {
|
||||
if (hasProperty(stringLiteralTypes, text)) {
|
||||
return stringLiteralTypes[text];
|
||||
const unescaped = unescapeIdentifier(text);
|
||||
if (hasProperty(stringLiteralTypes, unescaped)) {
|
||||
return stringLiteralTypes[unescaped];
|
||||
}
|
||||
|
||||
const type = stringLiteralTypes[text] = <StringLiteralType>createType(TypeFlags.StringLiteral);
|
||||
type.text = text;
|
||||
const type = stringLiteralTypes[unescaped] = <StringLiteralType>createType(TypeFlags.StringLiteral);
|
||||
type.text = unescaped;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user