Open
Description
@freenow/wave
version: 1.30.0
Relevant code
<SelectList
onChange={(option) => {
console.log(option.value); // "value" does not exist on type unknown
}}
options={[1, 2, 3].map((item) => ({ label: item, value: item }))}
/>
What was expected to happen?
Current behavior is to type options
as unknown[]
, and option
arg in onChange
callback as unknown
.
It leads to unnecessary casting. Moreover, the shape of option
is actually expected to be { label: string, value: string }
, the component won't work otherwise.
I would expect the option's type to extend { label: string, value: string }
and to be inferred from the list of provided options
Reproduction
https://codesandbox.io/s/wave-playground-4537vt?file=/src/App.tsx