Skip to content

Commit 435a854

Browse files
authored
add an example for SvelteHTMLElements
1 parent e786729 commit 435a854

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

documentation/docs/07-misc/03-typescript.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ In case you're writing a component that wraps a native element, you may want to
146146
</button>
147147
```
148148

149+
Not all elements have a specific type definition, in those cases, use `SvelteHTMLElements`:
150+
151+
```svelte
152+
<script lang="ts">
153+
import type { SvelteHTMLElements } from 'svelte/elements';
154+
155+
let { children, ...rest }: SvelteHTMLElements['div'] = $props();
156+
</script>
157+
158+
<div {...rest}>
159+
{@render children()}
160+
</div>
161+
```
162+
149163
## Typing `$state`
150164

151165
You can type `$state` like any other variable.

0 commit comments

Comments
 (0)