我可以毫无问题地设置模块别名:
"baseUrl": "./app",
"paths": {
"assets/*": ["assets/*"],
"components/*": ["components/*"],
...
},
这行得通。但是,我(实际上是我的客户,他想在将来将项目的某些部分提取为模块(想要创建子目录作为不同路径的别名(假设所有目录作为值都存在,并且我无法更改实际的目录结构(:
"paths": {
"assets/*": ["assets/*"],
"components/*": ["components/*"],
"@myapp/api/*": ["services/myapp/*"],
"@myapp/state/*": ["state/*"],
},
撇开这是否是一种好的模式/做法(因为我被要求这样做(,这在技术上是否可行而不触及物理目录结构(并且不使用第三方依赖项(?(我正在使用打字稿 3.4.3 和 Vscode 1.33.1(
"baseUrl": "./",
"paths": {
"@myapp/environment": [ "./src/environments/environment" ],
"@myapp/extensions": [ "./src/extensions" ],
"@myapp/testing": [ "./src/testing" ],
"@myapp/constants": [ "./src/app/shared/constants" ],
"@myapp/data": [ "./src/app/data" ],
"@myapp/shared": [ "./src/app/shared" ],
"@myapp/core/*": [ "./src/app/core/*" ],
"@myapp/*": [ "./src/app/*" ]
}
这就像我的项目的魅力