TS Compiler API - remove semicolons

Viewed 173

Typescript's printer automatically inserts semicolons, despite having omitTrailingSemicolon: true.

How do I prevent this behavior?

const file = ts.createSourceFile(
  "file",
  'const b = "asd"',
  ts.ScriptTarget.Latest,
  true,
  ts.ScriptKind.TS
);

const printer = ts.createPrinter({
  omitTrailingSemicolon: true,
  removeComments: false,
  newLine: ts.NewLineKind.LineFeed,
});
const printed = printer.printFile(file);
// const b = "asd";\n

0 Answers
Related