TypeScript使用不同版本的@types进行反应

时间:2018-11-02 21:13:02

标签: javascript reactjs typescript types

我已将compilerOptions中的tsconfig.json设置为以下paths

"paths": {
  "react": ["node_modules/@types/react"],
  "@types/react":  ["node_modules/@types/react"]
}

但是,我可以看到@types/react-router正在使用它自己的@types/react版本,这会导致编译错误,例如:

ERROR in /path/to/node_modules/@types/react-router/node_modules/@types/react/index.d.ts
    ERROR in /path/to/node_modules/@types/react-router/node_modules/@types/react/index.d.ts(2297,27)
       TS1005: ';' expected.

如何强制所有模块使用要包含的@types版本?

1 个答案:

答案 0 :(得分:0)

npm install @types/yourModule --save-dev

你可以尝试

请勿触摸tsconfig.json文件