因此,我将 Angular 8.2(项目模板)中的项目更新到版本 10,并按照https://update.angular.io/ 中的说明进行操作,一切正常,但是当实施路径映射时,痛苦开始了,我到处都有这个错误:
Cannot find module '@environments/environment' or its corresponding type declarations.ts(2307)
Run Code Online (Sandbox Code Playgroud)
这个错误适用于在路径中声明的@environments和@modules,其他的没有显示任何错误,因为它们没有被使用。
现在项目在使用ng build时正确构建,还没有尝试ng build --prod,没有出现错误,但Visual Studio Code (v1.46.1)向我显示了有错误的导入,这是我有:
源代码/tsconfig.json
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./e2e/tsconfig.json"
}
]
}
Run Code Online (Sandbox Code Playgroud)
src/tsconfig.app.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./lw/app",
"types": []
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"],
"exclude": ["src/test.ts", "src/**/*.spec.ts"]
}
Run Code Online (Sandbox Code Playgroud)
src/tsconfig.base.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "src", …Run Code Online (Sandbox Code Playgroud)