angular 路径别名设置问题解决方案
之前在项目根目录下的tsconfig.json文件中,配置path别名
baseUrl从当前目录开始,vscode可以出现智能提示,编译时出错。
error TS2307: Cannot find module '@lib/service/i18n.def/i18n.def' or its corresponding type declarations.
错误的样本
{ "compilerOptions": { "baseUrl": ".", "paths": { "@lib/common/*": [ "src/app/common/*" ], "@lib/service/*": [ "src/app/service/*" ] } } }
调整之后,编译通过,主要调整了baseUrl和paths的路径
{ "compilerOptions": { "baseUrl": "./src", "paths": { "@lib/common/*": [ "app/common/*" ], "@lib/service/*": [ "app/service/*" ] } } }