Closed
Description
I've seen multiple requests for TypeScript support.
This can be done in a few ways:
- Using the TS compiler API directly in the Svelte compiler for transforming scripts into components and then do type checking support against the template AST.
- Writing a compiler specifically for TS on top of the Svelte compiler with integration for Rollup, Webpack & Bazel.
The second approach is something I've taken a shot at, quite successfully I must say.
The compiler transpiles all scripts into valid JS that the Svelte compiler can transform into components and then it creates declaration files for the components, that the type checking then can consume later on to validate the components and templates.
It saves the AST compilation in a cache which then later on, the TS type checker is used to validate everything.
What's your opinion on this?
The repository can be found at https://github.com/marcus-sa/svelte-ts
Metadata
Metadata
Assignees
Labels
No labels