dylanT
dylanT

Reputation: 1110

How can I suppress spurious Typescript compilation errors in VS2017?

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.

enter image description here

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.

Upvotes: 4

Views: 4213

Answers (3)

Nalin
Nalin

Reputation: 93

I was able to get rid of the TS errors hence the build failures with below settings in VS 2019

Tools > Options > Text Editor > JavaScript/TypeScript > Code Validation > JavaScript Errors > Set the values under JavaScript Errors to False.

enter image description here

Upvotes: 3

dylanT
dylanT

Reputation: 1110

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: Settings for file extension association

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.

Upvotes: 1

Leo Liu
Leo Liu

Reputation: 76920

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.

Upvotes: 2

Related Questions