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.Dismiss alert
I know that <input type="number" /> has two value types: number | null, but svelte-check disagrees:
<scriptlang="ts">
exportlet value:number|null=null;
</script>
<inputtype="number"bind:value />
<!--Type 'number | null' is not assignable to type 'string | number | string[] | undefined'. Type 'null' is not assignable to type 'string | number | string[] | undefined'. -->
This is confusing to me, because I tend to erase inputs by setting value to null and now I'm forced to resort to undefined.
You can test it yourself with the following REPL:
<script>
let value =1;
</script>
<inputbind:valuetype="number" />
<p>null: {value===null}</p>
<p>undefined: {value===undefined}</p>
<p>typeof: {typeofvalue}</p>
<buttonon:click={() =>value=undefined}>undefined</button>
The text was updated successfully, but these errors were encountered:
Technically speaking the error is correct because you cannot set null to the input. It will be converted to an empty string by the browser. But the bind: will convert it to null.. so yeah I guess we need to relax the typings here.
I know that
<input type="number" />
has two value types:number | null
, butsvelte-check
disagrees:This is confusing to me, because I tend to erase inputs by setting value to
null
and now I'm forced to resort toundefined
.You can test it yourself with the following REPL:
The text was updated successfully, but these errors were encountered: