Angular 与2019年相比,ng cli更新至版本10后没有intellisense和验证
我已将.NET core 3.1+Angular 9.1更新为Angular 10.0.2, 我使用的步骤:Angular 与2019年相比,ng cli更新至版本10后没有intellisense和验证,angular,typescript,visual-studio,angular-cli,visual-studio-2019,Angular,Typescript,Visual Studio,Angular Cli,Visual Studio 2019,我已将.NET core 3.1+Angular 9.1更新为Angular 10.0.2, 我使用的步骤: 将Vs TypeScript更新为 运行ng update@angular/core@angular/cli 在这之后,VS2019 v16.6.3没有显示智能感知和验证,项目运行没有问题。 如果我在VS代码中打开项目,所有工作都很好 我发现问题就在我运行ng update@angular/cli 将项目恢复至9.1所有工程罚款 谢谢在将项目升级到Angular 10之后,我遇到了同样的
ng update@angular/core@angular/cli
ng update@angular/cli
将项目恢复至9.1所有工程罚款
谢谢在将项目升级到Angular 10之后,我遇到了同样的问题。最新版本的Visual Studio 2019没有处理对tsconfig.json文件和介绍tsconfig.base.json的更改,这似乎是一个问题 在VS 2019中解决此问题之前,我将tsconfig.base.json的内容复制到tsconfig.json,并注释掉升级后的配置 我现在有一个类似这样的文件,旧的功能被恢复
/*
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
It is not intended to be used to perform a compilation.
To learn more about this file see: https://angular.io/config/solution-tsconfig.
removed this as causes vs 2019 to fail - the config details are copied from base so when this is sort we can revert
"files": [],
"references": [
{
"path": "./src/tsconfig.app.json"
},
{
"path": "./src/tsconfig.spec.json"
},
{
"path": "./src/tsconfig.server.json"
},
{
"path": "./e2e/tsconfig.e2e.json"
}
]
*/
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"module": "esnext",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": true
}
}
从角度9迁移到角度10后,我遇到了完全相同的问题 我发现以下几点对我有用: TL;DR 在所有“项目”级别的tsconfig文件(tsconfig.app.json、tsconfig.spec.json、tsconfig.e2e.json)中,只需将“扩展”属性更改为:
{
"extends": "../tsconfig.json"
...
}
对下列事项:
{
"extends": "../tsconfig.base.json"
...
}
{
"files": [],
"references": [
{
"path": "./src/tsconfig.app.json"
},
{
"path": "./src/tsconfig.spec.json"
},
{
"path": "./e2e/tsconfig.e2e.json"
}
]
}
完整版本
在运行ng update
之前,我有以下结构:
ClientApp
|_ tsconfig.json
|_ src
|_ tsconfig.app.json
|_ tsconfig.spec.json
|_ e2e
|_ tsconfig.e2e.json
ClientApp
|_ tsconfig.json
|_ tsconfig.base.json
|_ src
|_ tsconfig.app.json
|_ tsconfig.spec.json
|_ e2e
|_ tsconfig.e2e.json
运行ng update
后,我有以下结构:
ClientApp
|_ tsconfig.json
|_ src
|_ tsconfig.app.json
|_ tsconfig.spec.json
|_ e2e
|_ tsconfig.e2e.json
ClientApp
|_ tsconfig.json
|_ tsconfig.base.json
|_ src
|_ tsconfig.app.json
|_ tsconfig.spec.json
|_ e2e
|_ tsconfig.e2e.json
阅读完角度迁移说明后,我注意到我的tsconfig.json
和tsconfig.base.json
版本是相同的。这仍然有效,但与笔记中描述的不符。所以我决定更改我的`tsconfig.json。手动执行以下操作:
{
"extends": "../tsconfig.base.json"
...
}
{
"files": [],
"references": [
{
"path": "./src/tsconfig.app.json"
},
{
"path": "./src/tsconfig.spec.json"
},
{
"path": "./e2e/tsconfig.e2e.json"
}
]
}
和其他人一样,它破坏了我的应用程序
因此,我查看了“项目”级别的tsconfig文件,发现“扩展”属性仍然指向tsconfig.json
,而不是tsconfig.base.json
。在将我的“项目”级别的tsconfig文件更新为指向tsconfig.base.json
文件后,一切正常
快乐的日子
:-)
我猜ng更新
应该“自动”找到并更新所有“项目”级tsconfig文件,但看起来好像没有。不过,解决办法相当直截了当
更新 虽然更改extends属性确实解决了我的编译问题。当我第二天关闭并重新打开Visual Studio时,IntelliSense开始出现故障
只有使
tsconfig.json
与tsconfig.base.json
相同,我才能使编译和IntelliSense工作。更新
这似乎在visual studio16.7.1中起作用
当更新到angular 10时,我面临同样的问题。这似乎是一个问题,并且修复程序已经在预览中可用
在修复程序向公众提供之前,请遵循tsconfig.json
中的更改为我解决问题
{
"extends": "./tsconfig.base.json"
}
非常好,这也解决了我的角度10的问题。不理想,但在修补程序完成之前仍有效。谢谢预计最新的VS2019预览版将解决此问题:不幸的是,截至16.7.2(20年8月18日),此问题尚未解决。在您的链接评论中有一条注释提到MS正在与Angular团队合作解决问题。VS代码似乎也有同样的问题