jacobworrel / react-windowed-select

An integration of react-window with react-select to efficiently render large lists.
MIT License
142 stars 38 forks source link

Types not declared for Typescript #17

Closed Sylv0 closed 4 years ago

Sylv0 commented 4 years ago

I would like to try this in a project I'm working on, but it's using Typescript and I am unable to import the module. If the types match react-select, is it possible to import it with those or declared them based on those?

jacobworrel commented 4 years ago

Hi @Sylv0 - I don't know much about Typescript unfortunately but I would be happy to accept a PR. I'm assuming the types would match react-select since this component is just a wrapper around their Select component but with a custom MenuList component.

alecmolloy commented 4 years ago

Bit late, but for any others, you can solve this pretty easily. @Sylv0 you are right and the types do work perfectly fine by mirroring them, you can do this by adding:

declare module 'react-windowed-select' {
  import { StateManager } from 'react-select'
  export default StateManager
}

in a missing types d.ts file in your project.

jacobworrel commented 4 years ago

Thanks @alecmolloy ! Closing this issue since the only non react-select prop the windowed select accepts is the windowThreshold (which should be a number type) - although I'm happy to reopen if anyone can figure out how to add typings for that.

brahimouindali commented 1 year ago

Hi, I'm using this amazing library in a nextjs+typescript project and I didn't get the right types for example onChange newValue gets a type of unknown instead of SingleValue. any help thanks