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">
interface $$Props extends Partial<HTMLInputElement> {
prop: string;
}
export let prop: string;
// ...
</script>
Oldest comments (0)