I'm currently exploring Svelte using TypeScript.
I encountered a TS23
error while working on this piece of code.
<script lang="ts">
import ComponentA from './ComponentA.svelte';
import ComponentB from './ComponentB.svelte';
let components = [
{ name: 'ComponentA', component: ComponentA },
{ name: 'ComponentB', component: ComponentB }
];
let selected;
</script>
{#each components as { name, component } (name)}
<label><input type="radio" value={component} bind:group={selected} />{name}</label>
{/each}
<svelte:component this={selected} />
Type 'typeof ComponentA__SvelteComponent_' is not assignable to type 'string | number | string[]'.
Type 'typeof ComponentA__SvelteComponent_' is missing the following properties from type 'string[]': pop, push, concat, join, and 28 more. ts(2322)
The error is related to the value
attribute within the input
tag.
Any suggestions on how to tackle this issue? I'm a bit lost here.