635f5bdf8c
1. `getRawLiteral()`: barf if `currentSourceFile` is missing, since if it is, then the following `getSourceTextOfNodeFromSourceFile` will return a bogus `""`. 2. One `||` -> `??` change. 3. `backtickQuoteEscapedCharsRegExp`: escape the usual control characters except for a simple LF. This code does get used to generate backtick strings when `rawText` is not given, and not escaping things like TAB characters can get mangled by editor settings. Worse, not escaping a CRLF and putting it verbatim in sthe string source will interpret it as LF, so add a special case for escaping these as `\r\n`. Added test. Related to #44313 and #40625.
12 lines
525 B
Plaintext
12 lines
525 B
Plaintext
=== tests/cases/compiler/templateLiteralsInTypes.ts ===
|
|
const f = (hdr: string, val: number) => `${hdr}:\t${val}\r\n` as `${string}:\t${number}\r\n`;
|
|
>f : Symbol(f, Decl(templateLiteralsInTypes.ts, 0, 5))
|
|
>hdr : Symbol(hdr, Decl(templateLiteralsInTypes.ts, 0, 11))
|
|
>val : Symbol(val, Decl(templateLiteralsInTypes.ts, 0, 23))
|
|
>hdr : Symbol(hdr, Decl(templateLiteralsInTypes.ts, 0, 11))
|
|
>val : Symbol(val, Decl(templateLiteralsInTypes.ts, 0, 23))
|
|
|
|
f("x").foo;
|
|
>f : Symbol(f, Decl(templateLiteralsInTypes.ts, 0, 5))
|
|
|