react-select/async and Typescript
See original GitHub issueHi!
I can’t seem to find a proper way to resolve this issue. When I try to import Async select I get a following TS error.
import SelectAsync from 'react-select/async';
Error:
Could not find a declaration file for module ‘react-select/async’. ‘<removed>/node_modules/react-select/async/dist/react-select.cjs.js’ implicitly has an ‘any’ type.ts(7016)
I found a couple of old threads online with the similar issue but none of the suggestions there could help. Any ideas how to resolve this?
Relevant packages from package.json:
"react-select": "^3.0.3",
"typescript": "^3.4.5",
"@types/react-select": "^2.0.19"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:26
- Comments:18 (3 by maintainers)
Top Results From Across the Web
TypeScript - React Select
React Select. A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete, async and creatable support. Star25,561.
Read more >react-select async loadOptions with TypeScript - Stack Overflow
I'm converting an existing react app to typescript, and I'm having trouble getting the react-select async loadOptions to parse correctly as ...
Read more >TypeScript react-select cheat sheet - SaltyCrane
This is a list of TypeScript types for react-select generated from the ... react-select/async; react-select/base; react-select/creatable; react-select/v1 ...
Read more >react-select-async-paginate - npm
Start using react-select-async-paginate in your project by ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made a PR to update the types: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/36464.
@StanBright and others looking for a TS workaround, here’s what I did to solve this problem for
react-select/creatable
. You should be able to do something similar forreact-select/async
:node_modules
subfolder in mysrc
folder. (not a typo-- put it inside your /src folder because you’ll want to check it into git!)./src/node_modules/react-select
folder./src/node_modules/react-select/creatable
folder./src/node_modules/react-select/creatable/index.d.ts
and populate it with this content: EDIT: added one more line to handle non-default exports (thanks @dhruvio!)Doing this enables imports like this to work:
Once the 3.0 typings are populated in DefinitelyTyped, you should be able to remove this hack.