How can I suppress spurious Typescript compilation errors in VS2017?

北城余情 提交于 2019-12-23 04:27:05

问题


We have a .Net project with some embedded resources that are xml files with a custom filename extension.

For some reason, on my computer, Visual Studio has suddenly (for the last few days) decided to treat these as TypeScript files and is producing tens of thousands of compile errors on each build.

The errors don't stop the build, but they do slow it down and make it hard to work out what the real errors are when I have them.

So far I've tried adding

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

to my csproj files, and I've looked at the "Compile on Save" setting for Javascript and it is not enabled. Neither of these fixes seem to work.

We don't have any TypeScript in our project at all.

I'm running Visual Studio 2017 15.5.7

Nobody else in my team is reporting this issue.


回答1:


How can I suppress spurious Typescript compilation errors in VS2017?

If you can make sure those build errors are Typescript compilation errors, you can try to following methods to suppress Typescript compilation errors:

Add TypeScript transpilation blocked in your project file .csproj(What you have done):

<PropertyGroup>
     <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>

Make sure you are including your typescript files as content:

<ItemGroup>
    <Content Include="**\*.ts" />
</ItemGroup>

Add a tsconfig.json file to your project root and make sure compileOnSave is set to false:

"compileOnSave": false,

If all above not help you and you don't have any TypeScript to compiled in our project, you can go to Tools -> Extensions & Updates, and disable Typescript Build for Microsoft Visual Studio.

Hope this helps.




回答2:


After some experimenting, I discovered how to suppress these messages in my circumstances.

At some point, I had registered a file extension as a type of file to be edited in VS with the XML editor. This is done via: Tools, Options, Text Editor, File Extension

I had added my file extension as an extension that should be edited with the XML editor like below:

After I removed the association, the compile errors stopped appearing.

I don't know what caused Visual Studio 2017 to decide that files to be opened in the XML editor should be treated as TypeScript files and compiled. However, the reason I added the extension no longer applies, so I happily removed it.



来源:https://stackoverflow.com/questions/49128453/how-can-i-suppress-spurious-typescript-compilation-errors-in-vs2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!