Skip to content

TS2304 Errors appear for excluded files in Visual Studio 2017 #15730

@RobertoPrevato

Description

@RobertoPrevato

Hi,
Premise: I looked carefully for existing issues but didn't find a working answer (although I found many speaking about the same topic).

I am working with Visual Studio 2017, on an ASP.NET MVC Core application where the front end will be implemented using React, ES6 and Babel. No TypeScript.
I have a node_modules folder, hidden in FS and excluded from project, which contains some source .ts files from an external library (react-router).

When I open the solution, after few minutes 4 errors appear as compilation error (TS2304 Cannot find name 'object')

Error

What I tried to do:

  1. Add following configuration to inside .csproj file + Close and Reopen solution
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  1. Disable JavaScript/TypeScript new service + Close and Reopen solution
    Disabled service

But this wasn't sufficient. To resolve, I needed to disable the TypeScript extension completely from VS and close every instance of VS 2017.

  1. Disable TypeScript extension
    Disabled TypeScript extension

Which in turn removed completely the "JavaScript/TypeScript" entry from Options / Text Editor settings.

Expected behavior:
TS2304 Errors should not appear for files that are not included in the project. In the same way as C# files that are not included in the project (or are not set to "Compile" build action) do not affect compilation (for example). This should not require any special action.

Actual behavior:
Behavior of TypeScript files is inconsistent with other programming languages used in VS. Compilation errors such as TS2304 are appearing also for files that are excluded from project and even hidden in file system.


Kind Regards,
Roberto

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueFixedA PR has been merged for this issueVisual StudioIntegration with Visual Studio

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions