Visual studio Visual Studio 2017 TS2304和TS2583在Angular项目中出错,但ng build工作正常
使用Angular模板启动.NETCore2.2项目。将/ClientApp文件夹替换为新的CLI生成的angular 7应用程序。VS构建和ng构建都没有问题。但是,在VS错误列表选项卡上,大约有16个TS相关错误,其中3个是Visual studio Visual Studio 2017 TS2304和TS2583在Angular项目中出错,但ng build工作正常,visual-studio,typescript,Visual Studio,Typescript,使用Angular模板启动.NETCore2.2项目。将/ClientApp文件夹替换为新的CLI生成的angular 7应用程序。VS构建和ng构建都没有问题。但是,在VS错误列表选项卡上,大约有16个TS相关错误,其中3个是 Error TS2304 (TS) Cannot find name 'Iterable'. Error TS2583 (TS) Cannot find name 'Map'. Error TS1219 (TS) Experimental suppor
Error TS2304 (TS) Cannot find name 'Iterable'.
Error TS2583 (TS) Cannot find name 'Map'.
Error TS1219 (TS) Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
这让我快发疯了。有人无意中发现了这个问题并解决了吗
我的tsconfig.json文件
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
[更新]
只是为了添加细节——我注意到所有错误都引用了同一个文件,这是我最近通过VS>addnewitem>typescript文件添加的文件。这会在csproj文件中添加文件引用,如下所示:
<!--<ItemGroup>
<None Remove="ClientApp\src\app\mycomponent\mysvc.service.ts" />
</ItemGroup>-->
<!--<ItemGroup>
<TypeScriptCompile Include="ClientApp\src\app\mycomponent\audit.service.ts" />
<TypeScriptCompile Include="ClientApp\src\app\shared\models\commodel-result.model.ts" />
</ItemGroup>-->
好的,在最终解决了这个问题,但仍然没有真正理解为什么这些类型开始引起麻烦之后,下面是我所做的。请参阅上面帖子中的更新。我注释掉了csproj文件中的文件引用,“伪”TS错误消失了 self和其他人注意-最好通过angular cli添加新的angular组件/服务文件,以避免出现这种情况