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
The inferred type of the options props in a multiple Select component is incorrect. For example, when passing a string[] type value to the options props, it is inferred as string[][].
Because of this, the type of the first argument of onChange props does not match the actual type of the value.
To Reproduce
Steps to reproduce the behavior:
Write the following component in TypeScript:
import{Select}from"@kobalte/core/select";import{createSignal,typeComponent}from"solid-js";typeFruit="apple"|"banana"|"cherry"|"orange"|"strawberry";constInvalidMultipleSelector: Component=()=>{const[values,setValues]=createSignal<Fruit[]>(["apple","banana"]);return(<Selectmultiplevalue={values()}onChange={(values)=>{setValues(values);// ^^^^^^ Following TypeScript error occurs here:// No overload matches this call.// The last overload gave the following error.// Argument of type 'Fruit[][]' is not assignable to parameter of type 'Fruit[] | ((prev: Fruit[]) => Fruit[])'.// Type 'Fruit[][]' is not assignable to type 'Fruit[]'.// Type 'Fruit[]' is not assignable to type 'Fruit'. ts(2769)}}options={["apple","banana","cherry","orange","strawberry"]asconst}></Select>);};
Expected behavior
A clear and concise description of what you expected to happen.
The type of options should not be inferred as a two-dimensional array.
import{Select}from"@kobalte/core/select";import{createSignal,typeComponent}from"solid-js";typeFruit="apple"|"banana"|"cherry"|"orange"|"strawberry";constInvalidMultipleSelect: Component=()=>{const[values,setValues]=createSignal<Fruit[]>(["apple","banana"]);return(<Selectmultiplevalue={values()}onChange={(values)=>{setValues(values);// ^^^^^^ Type of `values` should be `Fruit[]` not `Fruit[][]`}}options={["apple","banana","cherry","orange","strawberry"]asconst}></Select>);};
Additional context
Add any other context about the problem here.
No type error occurs if the type of option is explicitly specified:
The text was updated successfully, but these errors were encountered:
r4ai
changed the title
The inferred type of the value props in a multiple Select component is incorrect
The inferred type of the options props in a multiple Select component is incorrect
Sep 19, 2024
Describe the bug
The inferred type of the
options
props in a multiple Select component is incorrect. For example, when passing astring[]
type value to theoptions
props, it is inferred asstring[][]
.Because of this, the type of the first argument of
onChange
props does not match the actual type of the value.To Reproduce
Steps to reproduce the behavior:
Write the following component in TypeScript:
Expected behavior
A clear and concise description of what you expected to happen.
The type of
options
should not be inferred as a two-dimensional array.Additional context
Add any other context about the problem here.
No type error occurs if the type of option is explicitly specified:
The text was updated successfully, but these errors were encountered: