Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable typescript compilation in Visual Studio 2013

I am running grunt and have set up a typescript build process that listens for file changes, therefore I don't need the default VS compilation of my typescript files when I save or build my project.

I have unchecked the 'Compile on save' option under typescript in my project properties, but the ts files are still being compiled. The only way this works for me is if I set the build action of individual TS files to 'None', but this is still causing some Typescript files to be compiled. Is there any way this can be done in VS2013?

like image 885
juju Avatar asked Dec 11 '14 14:12

juju


People also ask

How do I disable TypeScript compilation in Visual Studio?

Currently, there are a few ways to "disable TypeScript" in VS. You could go to Tools > Options > Text Editor > JavaScript/TypeScript > Project and uncheck the Project Analysis options.

Does TypeScript compile to JavaScript?

TypeScript files are compiled to readable JavaScript, so that migration back is possible and understanding the compiled TypeScript is not hard at all.


3 Answers

In VS2015, a <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> setting can be added to the first <PropertyGroup> element in .csproj

msbuild output should then show

PreComputeCompileTypeScript:
  TypeScript compile is skipped because the TypeScriptCompileBlocked property is set to true.

From: http://rostacik.net/2015/08/14/how-to-disable-building-of-typescript-files-in-visual-studio-2015/

like image 94
Christopher Mott Avatar answered Oct 06 '22 07:10

Christopher Mott


I had the same question and solution that I found is to override TypeScript targets in the VS project file:

<Target Name="PreComputeCompileTypeScript">
  <Message Text="Skipping PreComputeCompileTypeScript" />
</Target>
<Target Name="CompileTypeScript">
  <Message Text="Skipping CompileTypeScript" />
</Target>
<Target Name="GetTypeScriptCopyToOutputDirectoryItems">
  <Message Text="Skipping GetTypeScriptCopyToOutputDirectoryItems" />
</Target>
like image 28
Dmitry Maltsev Avatar answered Oct 06 '22 09:10

Dmitry Maltsev


@Christopher Mott answer works also for Visual Studio 2013, at least for Update 5 and TypeScript Tools for Microsoft Visual Studio 2013 1.8.5.0. To be sure, one could verify if VS TypeScript toolchain understands that flag:

Open .csproj file for the intendend project and notice that it imports TypeScript targets from some:

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets

that generally maps to:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\<your VS version number>\TypeScript\Microsoft.TypeScript.targets

Inspect that file and look for TypeScriptCompileBlocked being defined (as false) in some <PropertyGroup>. If it's there, you're sorted. Go back to .csproj file and add the following, right after where TypeScript targets are imported:

<!-- Disable TypeScript compilation from within VS, leave that to external tools -->
<PropertyGroup>
  <TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
</PropertyGroup>
like image 30
superjos Avatar answered Oct 06 '22 07:10

superjos