JedWatson / JedWatson/react-select
onChange option type casting conflict with unknown.
Open
Nobody has claimed this yet.
issue/bug-unconfirmed
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
<Select
onBlur={onBlur}
onChange={(option: Option): void => {
onChange(option.value ?? '');
}}
options={productTypes}
placeholder="Select a product type"
value={value}
/>
Type '(option: Option) => void' is not assignable to type '(newValue: unknown, actionMeta: ActionMeta<unknown>) => void'.
Types of parameters 'option' and 'newValue' are incompatible.
Type 'unknown' is not assignable to type 'Option'.ts(2322)
Select.d.ts(164, 5): The expected type comes from property 'onChange' which is declared here on type 'IntrinsicAttributes & Props'
I am unable to typecast properly for onChange event, there is no specific documentation, whatever available online looks outdated.
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
Reproduce the TypeScript error with the Select example, then inspect Select.d.ts around the onChange declaration at line 164 and the related Select props types. Compare the declared callback parameters with the reported Option callback; done means the conflict is resolved or clearly documented with a verified usage pattern.
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