2

我从这里的一个开源项目开始:

https://github.com/vega/voyager

让它工作,我想添加一个模式。

所以我跑了:

yarn add react-modal
yarn add @types/react-modal

然后我补充说:

import {ReactModal} from 'react-modal';

我在 ./src/components/header/chrono-history.tsx (5,9) 中的构建错误中得到了这个:错误 TS2305: Module '"/Users/brennanwallace/psa/voyager/node_modules/@types/react -modal/index"' 没有导出的成员 'ReactModal'。

并且 web-storm 同意存在问题,因为它在文本编辑视口中给出了相同的错误。

我能做些什么?

我是键入脚本的新手,但文件似乎按顺序排列:

在 node_modules 的 @types 中有一个 react-modal 文件夹,其中 index.d.ts 与其他几个模块一样(它缺少其他包似乎具有的 types-metadata.json 文件)。

还有一个 react-modal 包。

tsconfig.json 文件似乎也按顺序排列:https ://github.com/vega/voyager/blob/vy2/tsconfig.json

4

1 回答 1

5

您必须将其导入为:

import * as ReactModal from 'react-modal';
于 2017-04-16T05:45:29.460 回答