Replies: 1 comment 1 reply
-
We do not expose that today, however I have a PR that added some new tool that included the need to expose it https://github.com/microsoft/typespec/pull/4383/files#diff-f1970e6a8b9b68f5eb9cb0acd29a78932e907bfbb05bbb0bd456bb506d885563 There is a few things to watch out there is still some nodes that are not formatted or by design just keep the original text(e.g. a string node) and for that the nodes compute the original text from the original document. That pr does fix some of the cases and allow passing the |
Beta Was this translation helpful? Give feedback.
-
I want an AST printer API that prints AST node(s) to string or a file. This will help creating tools like (something) to TypeSpec converter, or generating TypeSpec files from scratch.
There is an AST printer for formatting TypeSpec files with Prettier API, but it is not exported and can't be used outside the compiler:
https://github.com/microsoft/typespec/blob/main/packages/compiler/src/formatter/print/printer.ts
Is there any plan to expose this API or creating a new API for printing AST?
Beta Was this translation helpful? Give feedback.
All reactions