Feature request
Summary
The Slider accepts values of type Array<number> | number but the onValueChange and onValueCommitted callbacks don't narrow the type of the value parameter to number or Array<number> and users need to type cast it manually.
Example of code throwing a TS error:
// ❌ Argument of type 'number | number[]' is not assignable to parameter of type 'SetStateAction<number>'.
// Type 'number[]' is not assignable to type 'SetStateAction<number>'.
const [value, setValue] = React.useState(25);
<Slider.Root value={value} onValueChange={(value) => setValue(value}>
Example of type casting needed to overcome the TS error:
const [value, setValue] = React.useState(25);
<Slider.Root value={value} onValueChange={(value) => setValue(value as number}>
Motivation
Avoid users needing to do manual type casting.
Feature request
Summary
The
Slideraccepts values of typeArray<number> | numberbut theonValueChangeandonValueCommittedcallbacks don't narrow the type of thevalueparameter tonumberorArray<number>and users need to type cast it manually.Example of code throwing a TS error:
Example of type casting needed to overcome the TS error:
Motivation
Avoid users needing to do manual type casting.