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>- ✓Correct answer: Add
lang="ts"to<script>and type the props of$props() - 2Rename the file to
.svelte.tsx - 3TypeScript isn't supported in components
Explanation
sv check (svelte-check) type-checks templates as well.