react-component / react-component/select
A typescript user should be able to specify the types for the options
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 938
- Forks
- 482
- Avg merge
- 15h 8m
- Merged PRs (30d)
- 2
Description
Expected behavior:
I should be able to specify the strict option types as follows:
export const exampleComponent= () => {
type SelectValues = 'jack' | 'lucy' | 'disabled' | 'Yiminghe';
return (
<div style={{ width: '250px' }}>
<VtxSelect<SelectValues> size="middle" onChange={action('on-change')} defaultValue="jack">
<VtxOption<SelectValues> value="jack">Jack</VtxOption>
<VtxOption<SelectValues> value="lucy">Lucy</VtxOption>
<VtxOption<SelectValues> value="disabled" disabled>
Disabled
</VtxOption>
<VtxOption<SelectValues> value="Yiminghe">yiminghe</VtxOption>
</VtxSelect>
</div>
);
};
Actual Behavior:
I get the error Expected 0 type arguments, but got 1.ts(2558)
Contributor guide
No contributing guide indexed for this repository
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 locating the TypeScript declarations for the VtxSelect and VtxOption components named in the example. Reproduce the Expected 0 type arguments error with the generic usage shown, then verify that the declared option value type is accepted and incompatible values are rejected by TypeScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100