'Could not find a declaration file for module error in react
Typescript beginner here, trying to implement splitter to my project, i'm using SplitPane from "react-split-pane/lib/SplitPane" and Pane from "react-split-pane/lib/Pane" in my typescript project but its giving me this error:
Could not find a declaration file for module 'react-split-pane/lib/Pane'. 'C:/.../node_modules/react-split-pane/lib/Pane.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-split-pane` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-split-pane/lib/Pane';`ts(7016)
it is working correctly without problem but still giving me that, it suggests to try '@types/react-split-pane' but that is not working anymore 'https://www.npmjs.com/package/@types/react-split-pane' 'This package has been deprecated'.
as i said in comments i imported it like this :
import SplitPane from "react-split-pane/lib/SplitPane";
import Pane from "react-split-pane/lib/Pane";
Any idea how to get rid of error ?
English is not my mother language so the could be mistakes.
my splitpane module:
Solution 1:[1]
i'm importing it like this : import SplitPane from "react-split-pane/lib/SplitPane"; import Pane from "react-split-pane/lib/Pane";
You really should never go drilling into the directory structure of libraries for imports, unless the documentations specifically tells you to.
According to the index file of that library, that's now how you are expected to import the values. The library exports like this:
export default SplitPane;
export { Pane };
And that means you should import those two values like this:
import SplitPane, { Pane } from 'react-split-pane'
It also works in a code sandbox with a full project:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex Wayne |

