Typescript Error: Could not find a declaration file for module 'react-dnd'

982 views Asked by At

I am currently getting this error when importing react-dnd:

Could not find a declaration file for module 'react-dnd'. 'node_modules/react-dnd/lib/index.js' implicitly has an 'any' type.
Try `npm install @types/react-dnd` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-dnd';

Doesn't react-dnd provide type definitions? Is there anything extra I have to do to get access to the types?

I am using typescript in strict mode. My app was scaffolded with create-react-app.

1

There are 1 answers

1
TLadd On BEST ANSWER

react-dnd does indeed ship with type definitions as you can see here in unpkg. You shouldn't need to do anything to access these types. Perhaps you are using an older version of react-dnd that does not have the types included?