tsconfig提示aliased imports are not supported解决方案

问题详情:react-ts项目中配置路径提示不支持别名导入

compilerOptions. paths must not be set (aliased imports are not supported)

解决方案:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//新建tsconfig.paths.json文件

//在该文件中写入路径配置
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@@/*": ["./*"],
"@/*": ["src/*"],
"@data": ["src/data/*"]
}
}
}

//将此文件引入tsconfig.json文件
{
...
"extends": "./tsconfig.paths.json"
}

解决方案来源:

https://github.com/facebook/create-react-app/issues/5118