Svelte · Junior · Question 64 of 76

How do you use TypeScript in a Svelte component?

<script lang="ts">
  interface Props { title: string; count?: number }
  let { title, count = 0 }: Props = $props();
</script>

Explanation

sv check (svelte-check) type-checks templates as well.

Further reading

Problem with a question

Svelte · Junior · question 64

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz