How can I suppress spurious Typescript compilation errors in VS2017?

We have a .Net project with some built in resources which are xml files with custom filename extension.

For some reason, on my computer, Visual Studio has suddenly (over the past few days) decided to treat them as TypeScript files, and produces tens of thousands of compilation errors for each assembly.

enter image description here

Errors don't stop the build, but they slow it down and make it difficult to deal with real errors when I use them.

So far I have tried to add

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

      

to my csproj files and I looked at the Compile on Save option for Javascript and it is not enabled. None of these fixes work.

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

I am running Visual Studio 2017 15.5.7

No one on my team is reporting this issue.

0


source to share


2 answers


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

At some point, I registered the file extension as a file type for editing in VS with an XML editor. This is done via: Tools, Options, Text Editor, File Extension

I have added my file extension as an extension to be edited with an XML editor like below: Settings for file extension association



After I removed the association, the compilation errors stopped showing up.

I don't know why Visual Studio 2017 decided that the 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.

0


source


How can I suppress spurious Typescript compilation errors in VS2017?

If you can verify that the build errors are Typescript compilation errors, you can try the following methods to suppress the Typescript compilation errors:

Add Typescript transpilation locked in the project .csproj file (what you did):

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

      

Make sure you include the Typescript files as content:



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

      

Add the tsconfig.json file to your project root and make sure the parameter is compileOnSave

set to false:

"compileOnSave": false,

      

If all of the above doesn't help you and you don't have any Typescript to compile in our project, you can go to Tools → Extensions & Updates and disable Typescript Build for Microsoft Visual Studio .

Hope it helps.

+1


source







All Articles