Add lang="ts"
to a component's script tag to enable TypeScript.
Props & data are regular variables and can be types as such.
Events are regular HTML events.
A text editor with Svelte support will understand the types in templates.
Since Svelte <script>
code is plain JavaScript, Svelte has great TypeScript support.
In this example, we'll review how to use TypeScript with Svelte.
Add lang="ts"
to a component's script tag to enable TypeScript.
Props & data are regular variables and can be types as such.
Events are regular HTML events.
A text editor with Svelte support will understand the types in templates.
Further reading on this topic.