Ignore TS7027 warnings from third-party javascript files in VS2017?

I have a project using Handlebars, and Visual Studio 2017 displays dozens of "TS7027: Unreachable code detected" warnings from the Handlebars js files. I don’t even use Typescript in this project, so it’s not clear why this error appears, but this is a real problem, since I have to filter almost 50 TS7027 warnings in order to find warnings that are actually relevant. So, is there a way to ignore these warnings (I don’t think after some Googling) or better, tell Typescript not to parse any of my .js files?

Edit: I followed the instructions in the answer to this question ( How to prevent visual studio 2017 from building javascript? ), But still seeing warnings. They are present at the first opening of the project, before I explicitly save or build, so disabling TS compilation in the save / build file is not a solution for this. As a workaround, I disabled the Typescript extension in VS2017.

+8
typescript visual-studio-2017
source share
1 answer

As far as I can tell from your question, you want to suppress all TS7027 warnings for a specific project. This script can be done in Visual Studio as follows:

  • In Visual Studio, select your project> Properties> Build
  • In the Errors and Warnings section, list all warnings separated by commas to suppress

See this screenshot for your case:

Disable special warnings in Visual Studio 2017

This solves the problem by ignoring these specific warnings - for this particular project.

Now, if you want to disable / disable TypeScript to fully compile for this particular project, you can add the following line to your .csproj in the PropertyGroup section:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 

More information about this can be found in How to prevent visual studio 2017 from javascript assembly? , here at StackOverflow.

0
source share

All Articles