user3091275 user3091275 - 2 months ago 34
React JSX Question

Material-UI dependencies: ''react-tap-event-plugin'' has no exported member 'injectTapEventPlugin'

I'm working with react/typescript/material-ui/webpack. Material-UI has a dependency to

react-tap-event-plugin
and I am having issues importing the injectTapEventPlugin function, here is the error I got:

error TS2305: Module ''react-tap-event-plugin'' has no exported member 'injectTapEventPlugin'.


To add the definition for
react-tap-event-plugin
I used the following command:

sudo typings install dt~react-tap-event-plugin --save --global --save-dev


The index.d.ts looks like this:

declare module 'react-tap-event-plugin'{
interface StrategyOverrides {
shouldRejectClick?: (lastTouchEventTimestamp: Date, clickEventTimestamp: Date) => boolean;
}

var injectTapEventPlugin: (strategyOverrides?: StrategyOverrides) => void;

export = injectTapEventPlugin;
}


I am trying to import the plugin in my App using:

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


Any idea on what I am missing?

Answer

Taken from the test file in the github project

// since the export is a function, this is the only actual correct way:
import injectTapEventPluginRequire = require("react-tap-event-plugin");

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/react-tap-event-plugin/react-tap-event-plugin-tests.ts

Comments