我已将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版本?
答案 0 :(得分:0)
npm install @types/yourModule --save-dev
你可以尝试
请勿触摸tsconfig.json文件