JedWatson / JedWatson/react-select
Typescript: Return selectProps.value correct type based on IsMulti type instead of union type
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi everyone,
I've noticed that there is a union type for a value field instead of a single type for value field based on IsMulti generic type:
export type PropsValue<Option> = MultiValue<Option> | SingleValue<Option>;
I think we should use something like this:
export declare type PropsValue<Option, IsMulti extends boolean> = IsMulti extends true ? MultiValue<Option> : SingleValue<Option>;
to return the correct value type based on IsMulti generic type.
If you agree I can work on that fix.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the PropsValue and IsMulti type declarations in the TypeScript sources and locating how selectProps.value uses them. Confirm the intended inference for single- and multi-select cases, then verify that the resulting value type is no longer an unconditional union with the relevant type checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100