JedWatson / JedWatson/react-select

onChange option type casting conflict with unknown.

Open
#5,699 10 comments 11 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.