xeho91 / svelte-ast-print

Print Svelte AST nodes as string. Aka parse in reverse.
https://xeho91.github.io/svelte-ast-print/
MIT License
7 stars 1 forks source link

Add support for TypeScript #86

Open xeho91 opened 2 months ago

xeho91 commented 2 months ago

Blockers

  1. esrap does not support TypeScript AST nodes - attempting to see if maintainers are interested in expanding support for TypeScript - https://github.com/Rich-Harris/esrap/issues/10
  2. Concluding my research, I couldn't find an existing AST printer package which support TypeScript syntax and their respective AST nodes
manuel3108 commented 1 month ago

Alright, since #90 did not work as expected, I gave this another try. This time by modifying esrap. You can find my POC here: https://github.com/Rich-Harris/esrap/pull/13

When you have downloaded both repos (this one and esrap) in the same directory, you can link them together with this command:

pnpm link ../esrap # executed from your `svelte-ast-print` working directory

After that make sure to remove the relevant .fails from the tests (expect #92) and run pnpm test as usually. This makes all relevant tests succeed, with some minor stylistic differences.

At this point the PR is still a POC, but I'm way more confident that we will succeed with this than with #90. There is still tons to be done, but it should be a good starting point.