You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
The
unknown
part is generated by language-tools. But without that, it will still be inferred as
any
. Not sure if it makes sense to allow it since it isn't how typescript inferred the type for destructuring.
So I guess there is no special return type for
$bindable
? Is this good?
<scriptlang="ts">typeProps= { b:boolean };let { b =$bindable<boolean>() }:Props=$props();</script>
Wished this was documented in the
$bindable
preview documentation.
I know TypeScript object must be typed as a whole, but still:
If default values are provided, manual typing might not be necessary:
<scriptlang="ts">let {// Only this prop needs typing,// but the whole Props should be typed. showModal =$bindable<boolean>(), closeWithBackdropClick =false, onclose = (() => {}) as () =>unknown } =$props();</script>
props and the Props type can mismatch:
<!-- src/lib/Component.svelte -->
<scriptlang="ts">// Even-though the fallback value has been provided,let { b =$bindable(false) }:Props=$props();// Since it is not a optional key in the Props type:typeProps= { b:boolean };</script>
<!-- src/routes/+page.svelte -->
<script>importComponentfrom'$lib/Component.svelte';</script>
<!-- Property 'b' is missing in type '{}' but required in type 'Props'. -->
<Component></Component>