Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings of SelectList lead to unnecessary type casts #371

Open
alatielle opened this issue Aug 30, 2023 · 0 comments
Open

Typings of SelectList lead to unnecessary type casts #371

alatielle opened this issue Aug 30, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@alatielle
Copy link
Contributor

alatielle commented Aug 30, 2023

  • @freenow/wave version: 1.30.0

Relevant code

      <SelectList
        onChange={(option) => {
          console.log(option.value); // "value" does not exist on type unknown
        }}
        options={[1, 2, 3].map((item) => ({ label: item, value: item }))} 
      />

What was expected to happen?

Current behavior is to type options as unknown[], and option arg in onChange callback as unknown.
It leads to unnecessary casting. Moreover, the shape of option is actually expected to be { label: string, value: string }, the component won't work otherwise.

I would expect the option's type to extend { label: string, value: string } and to be inferred from the list of provided options

Reproduction

https://codesandbox.io/s/wave-playground-4537vt?file=/src/App.tsx

@nlopin nlopin added the enhancement New feature or request label Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants