Fix template string escaping (#60303)
This commit is contained in:
Родитель
df9d16503f
Коммит
e6ef279403
|
@ -6064,7 +6064,7 @@ export function hasInvalidEscape(template: TemplateLiteral): boolean {
|
|||
const doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
// Template strings preserve simple LF newlines, still encode CRLF (or CR)
|
||||
const backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u0009\u000b-\u001f\u2028\u2029\u0085]/g;
|
||||
const escapedCharsMap = new Map(Object.entries({
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
|
|
|
@ -358,5 +358,13 @@ describe("unittests:: PrinterAPI", () => {
|
|||
),
|
||||
ts.createSourceFile("source.ts", "", ts.ScriptTarget.ES2015),
|
||||
));
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/59150
|
||||
printsCorrectly("template string", {}, printer =>
|
||||
printer.printNode(
|
||||
ts.EmitHint.Unspecified,
|
||||
ts.factory.createNoSubstitutionTemplateLiteral("\n"),
|
||||
ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext),
|
||||
));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
`
|
||||
`
|
Загрузка…
Ссылка в новой задаче