Skip to content

Commit a60b103

Browse files
Merge pull request microsoft#18077 from fwouts/regex-bug
Fix microsoft#18071: Printer failure when encountering RegularExpressionLiteral
2 parents 278dcc6 + 170bc6f commit a60b103

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ namespace ts {
359359
case SyntaxKind.TemplateTail:
360360
return "}" + escapeText(node.text, CharacterCodes.backtick) + "`";
361361
case SyntaxKind.NumericLiteral:
362+
case SyntaxKind.RegularExpressionLiteral:
362363
return node.text;
363364
}
364365

src/harness/unittests/printer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ namespace ts {
5656

5757
// github #14948
5858
printsCorrectly("templateLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let greeting = `Hi ${name}, how are you?`;", ScriptTarget.ES2017)));
59+
60+
// github #18071
61+
printsCorrectly("regularExpressionLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let regex = /abc/;", ScriptTarget.ES2017)));
5962
});
6063

6164
describe("printBundle", () => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let regex = /abc/;

0 commit comments

Comments
 (0)