'Visual Studio (2017 & 2019) ignoring TypeScriptCompileBlocked

I have been having some problems with Visual Studio compiling Typescript files, this causes a HUGE headache since the compiled .js files will be used first instead of using the files generated by SPA Development Server when the project is run.

I created a React Application (create-react-app my-app --typescript) and things work just fine until I add a new .tsx file. For some reason VS will always compile the file if added through the Solution Explorer.

I made sure that Typescript compiling was disabled in the .csproj

<PropertyGroup>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    {...}
</PropertyGroup>

One thing I did notice is when I add a new .tsx file VS will put a couple of entries into the project file:

<ItemGroup>
    <None Remove="<project>\src\<file>.tsx" />
</ItemGroup>

<ItemGroup>
    <TypeScriptCompile Include="<project>\src\<file>.tsx" />
</ItemGroup>

The interesting thing is when I remove these entries from the Project it will still compile until I restart VS, is there a way to force Visual Studio to not compile any Typescript files and not add them to the project file or is this just another bug in VS to workaround?



Solution 1:[1]

I used this in my csproj to resolve problem

<PropertyGroup>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    <TypeScriptNoEmitOnError>true</TypeScriptNoEmitOnError>
    <TypeScriptNoImplicitReturns>true</TypeScriptNoImplicitReturns>
    <TypeScriptEnableIncrementalMSBuild>false</TypeScriptEnableIncrementalMSBuild>
</PropertyGroup>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Grzegorz G.