【发布时间】:2019-11-25 22:41:13
【问题描述】:
我正在尝试通过将这些值添加到 tsconfig.json 来在我的项目中设置路径别名:
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@store/*": ["store/*"]
},
如果我创建导入,IntelliJ 或 VSCode 都不会打扰我:
import { AppState } from '@store/index';
但是当我编译应用程序时,我收到了这个警告:
The following changes are being made to your tsconfig.json file:
- compilerOptions.paths must not be set (aliased imports are not supported)
它会说它找不到参考:
TypeScript error in C:/xyz.tsx(2,26):
Cannot find module '/store'. TS2307
是否有任何解决方法或create-react-app --typescript 不支持?
【问题讨论】:
-
你使用自定义 webpack 吗?
-
是的,我确实使用 react-app-rewired 来自定义 webpacks
标签: typescript create-react-app