When using Svelte with TypeScript, all properties of a component should be typed. Props are declared by exporting a let
. However, when creating a superset of an HTML element, one wouldn't want to extensively declare all props. Here's a solution for this:
<script lang="ts"> import type { HTMLInputAttributes } from 'svelte/elements'; interface $$Props extends HTMLInputAttributes { prop: string; } export let prop: string; // ... </script>
Top comments (0)