我试图通过将这些值添加到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
不支持?