-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working
Description
Describe the problem
Currently, the following code:
<script lang="ts">
export let firstSelected = true;
</script>
<input type="radio" bind:group={firstSelected} value={true}/>
<input type="radio" bind:group={firstSelected} value={false}/>Raises the following type error:
Error: Type 'true' is not assignable to type 'string | number | string[]'. (ts)
Error: Type 'false' is not assignable to type 'string | number | string[]'. (ts)
(see https://stackoverflow.com/questions/65841762/bind-radio-group-to-a-boolean-value-using-svelte )
Describe the proposed solution
boolean could be accepted as a radio input value
Alternatives considered
A working alternative is to just let the user code their own two-way binding, but that is not very clean, and may be error-prone:
<script lang="ts">
export let firstSelected = true;
$: _firstSelected = Number(firstSelected);
function handleChange(e) {
firstSelected = Boolean(_firstSelected);
}
</script>
<input type="radio" bind:group={_firstSelected} value={1} on:change={handleChange}/>
<input type="radio" bind:group={_firstSelected} value={0} on:change={handleChange}/>Importance
would make my life easier
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.bugSomething isn't workingSomething isn't working