BT

InfoQ Homepage News Svelte Adds Official TypeScript Support

Svelte Adds Official TypeScript Support

Bookmarks

The Svelte JavaScript framework leverages TypeScript, but until recently, it was challenging to use TypeScript to create Svelte web apps. The latest Svelte updates add official TypeScript support to Svelte.

As explained by TypeScript team member Orta Therox:

It's been by far the most requested feature for a while, and it's finally here: Svelte officially supports TypeScript. We think it'll give you a much nicer development experience — one that also scales beautifully to larger Svelte code bases — regardless of whether you use TypeScript or JavaScript.

Before this update, using TypeScript with Svelte required combining many different tools. TypeScript support in Svelte allows TypeScript within script blocks, type checking of Svelte components, auto-completion hunts when authoring components and their markup, and TypeScript understanding the Svelte component API.

To get started with TypeScript with Svelte, developers should install the Svelte template and Svelte TypeScript app and run a TypeScript setup script:

npx degit sveltejs/template svelte-typescript-app
cd svelte-typescript-app
node scripts/setupTypeScript.js

There is also now a Svelte TypeScript VSCode extension available. It is also possible to add TypeScript support to existing Svelte projects. TypeScript support for the Sapper framework on top of Svelte is currently under development.

Bringing TypeScript support to Svelte was a substantial community effort among many different developers to bring their separate extensions together to form Svelte's official TypeScript support. Changes were needed to support TypeScript transpilation and TypeScript Language Services support for improvements to the IDE experience.

Svelte and its TypeScript support are open source software available under the MIT license. Contributions are welcome under the Svelte contribution guidelines.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.