Skip to content

Working TS compiler & AST type checkerΒ #3677

Closed
@marcus-sa

Description

@marcus-sa

I've seen multiple requests for TypeScript support.

This can be done in a few ways:

  1. 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.
  2. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions