I am trying to import components from react-materialize as -
import {Navbar, NavItem} from \'react-materialize\';
But when the webpack is
For my case the issue was that the types were not getting added to package.json file under devDependencies to fix it I ran npm install --save-dev @types/react-redux note the --save-dev
I had this issue when I added react-router-dom to the new CRA app using typescript. After I added @types/react-router, the issue was fixed.
A more hacky way is to add eg., in boot.tsx the line
import './path/declare_modules.d.ts';
with
declare module 'react-materialize';
declare module 'react-router';
declare module 'flux';
in declare_modules.d.ts
It works but other solutions are better IMO.
works just fine
npm install @types/react-materialize
I had a similar error but for me it was react-router. Solved it by installing types for it.
npm install --save @types/react-router
Error:
(6,30): error TS7016: Could not find a declaration file for module 'react-router'. '\node_modules\react-router\index.js' implicitly has an 'any' type.
If you would like to disable it site wide you can instead edit tsconfig.json and set noImplicitAny to false.
Also, this error gets fixed if the package you're trying to use has it's own type file(s) and it's listed it in the package.json typings attribute
Like so:
{
"name": "some-package",
"version": "X.Y.Z",
"description": "Yada yada yada",
"main": "./index.js",
"typings": "./index.d.ts",
"repository": "https://github.com/yadayada.git",
"author": "John Doe",
"license": "MIT",
"private": true
}