我正在尝试映射 tsconfig.json 中的路径以摆脱相对路径地狱。我的React App 基于 Create-React-App。
我试过这个所以线程 https://stackoverflow.com/questions/43281741/how-to-use-paths-in-tsconfig-json并在我的 tsconfig.json 中添加了路径。我的 tsconfig.json 是
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"strictNullChecks": false
},
"include": [
"src"
]
}
当我在 VS Code 中编译项目时,它会从 tsconfig.json 中删除路径条目,并显示以下消息。为什么我的系统不支持别名导入反应脚本基于 React 项目?