bug(Printer): LF newline in template strings is escaped when it shouldn't be #59150
Labels
Bug
A bug in TypeScript
Domain: Transforms
Relates to the public transform API
Fix Available
A PR has been opened for this issue
Milestone
π Search Terms
template strings new line newline escape LF backslash emit print
π Version & Regression Information
β― Playground Link
https://github.com/maxpatiiuk/typescript-bug-needless-lf-escaping/tree/main
π» Code
π Actual behavior
LF new lines in template literal strings are escaped
π Expected behavior
As the comment in TypeScript's source code states, LF new lines in backticks should not be escaped:
https://github.com/microsoft/TypeScript/blame/3163fe7e3898c1f48cd9bc097b96e3426cd2a453/src/compiler/utilities.ts#L5925-L5926
However, that RegExp has a bug - the regex has a
\u0000-\u001f
character range, which includes the LF character (\u000a
)The RegExp should be modified to not match
\u000a
(\n
). Potentially like so:Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: