Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type

前端 未结 14 1198
鱼传尺愫
鱼传尺愫 2020-12-05 09:09

I am trying to import components from react-materialize as -

import {Navbar, NavItem} from \'react-materialize\';

But when the webpack is

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 09:48

    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
    }
    

提交回复
热议问题