我刚开始在我的 React 项目中添加 TypeScript,我想不出这个错误:
import {Link} from 'react-router';
Module '"/Users/.../node_modules/@types/react-router/index"' has no exported member 'Link'.
该Link
组件存在于react-router
(代码正在运行)中,但 TypeScript 无法识别它。我已经添加了@types/react-router
,但似乎没有实现Link
. 有任何想法吗 ?
摘自我的package.json
:
"@types/react": "^15.0.25",
"@types/react-dom": "^15.5.0",
"@types/react-router": "^4.0.11",
"@types/reactstrap": "^4.3.4",
...
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router": "^3.0.2",
"reactstrap": "^4.2.0"
...
"typescript": "^2.3.3",