Skip to content

Printer breaks when there is \ in string literal in jsx attrs #35054

@kgtkr

Description

@kgtkr

TypeScript Version: typescript@3.8.0-dev.20191105

Search Terms:
compilar api

Code

fs.writeFileSync(
  "out",
  ts
    .createPrinter()
    .printFile(
      ts.createSourceFile(
        "test.ts",
        fs.readFileSync("in", { encoding: "utf8" }),
        ts.ScriptTarget.ESNext,
        undefined,
        ts.ScriptKind.TSX
      )
    )
)

in

<a x="\\"/>

Expected behavior:

out

<a x="\\"/>

Actual behavior:
out

<a x="\\\\"/>

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: APIRelates to the public API for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions