Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import react-tap-event-plugin with from node_modules typescript

I am trying to learn react and typescript. And would like to include material-ui in my project. From there homepage I am instructed to install react-tap-event-plugin, which I did and "node_modules/react-tap-event-plugin" does exist!

Now I am supposed to to do this:

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

but the typescript compile tells me, that it cannot find the module.

I tried different variants (using require, importing node_mdules/...), but nothing worked.

How do I set this up correctly?

This is my package.json:

{
  "private": true,
  "scripts": {
    "dev": "lite-server"
  },
  "dependencies": {
    "react": "^0.14.0",
    "react-dom": "^0.14.0",
    "fbjs": "^0.2.1",
    "react-tap-event-plugin": "0.2.0",
    "material-ui": "^0.14.0"
  }
}
like image 430
Nathan Avatar asked Mar 13 '23 03:03

Nathan


1 Answers

You need to install definition file (.d.ts) for react-tap-event-plugin. You can do it with typings by executing the following :

  • if you don't have typings installed npm install typings --global
  • typings install dt~react-tap-event-plugin --save

Also, be sure to reference typings/index.d.ts in tsconfig.json.

like image 145
Fidan Hakaj Avatar answered Mar 16 '23 10:03

Fidan Hakaj