Type inference for selectProps.value #5801
davidmason
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have to cast
props.selectProps.value
to a single value or array to use it in a custom component, even though the second type argumentIsMulti
is specified. It should be possible to have the type inferred forvalue
.value
has typePropsValue<Option>
, defined here:react-select/packages/react-select/src/types.ts
Line 18 in 17ab36e
It could take a second type argument
IsMulti
and narrow to a single or multi value when possible based on that. It could still be the union of both types if IsMulti is not locked down to true or false.Aside: a similar thing is done in the OnChangeValue definition right after, but its needs to lock in one or the other so defaults to single without a definite
false
.It would just need IsMulti passed through as a second type parameter where Props are defined for Select, here:
react-select/packages/react-select/src/Select.tsx
Line 274 in 17ab36e
I don't know if this would break how
PropsValue
is used elsewhere, but superficially it looks like a positive change. Happy to hear what I've missed.Beta Was this translation helpful? Give feedback.
All reactions