svelte-headlessui
svelte-headlessui copied to clipboard
[svelte updated feature] Native HTML props are supported in typing!
This comment about typing might be useful to this library:
How to extend prop types from HTML elements
For everyone who wants to create a wrapper component around a certain HTML element and wants a way to type "this component accepts all properties of X", here's how you do it as of Svelte version 3.55:
<script lang="ts"> import type { HTMLButtonAttributes } from 'svelte/elements'; interface $$Props extends HTMLButtonAttributes { error: boolean; // your own additional typings } export let error: boolean; // ... </script> <!-- ... --> <button> <slot /> </button>
Svelte version 3.55 comes with a new
svelte/elements
export which contains typings for all regular HTML elements. It will also power the next major version ofsvelte-check
.
Originally posted by @dummdidumm in https://github.com/sveltejs/language-tools/issues/442#issuecomment-1359423782