1 | import { ts } from 'ts-morph';
|
2 |
|
3 | export class TsPrinterUtil {
|
4 | private printer: ts.Printer;
|
5 |
|
6 | constructor() {
|
7 | this.printer = ts.createPrinter({
|
8 | newLine: ts.NewLineKind.LineFeed
|
9 | });
|
10 | }
|
11 |
|
12 | public print(node: ts.Node): string {
|
13 | return this.printer.printNode(
|
14 | ts.EmitHint.Unspecified,
|
15 | node,
|
16 | ts.createSourceFile('', '', ts.ScriptTarget.Latest)
|
17 | );
|
18 | }
|
19 | }
|