Conditional Compilation is not yet available in TypeScript, some requests and proposals have been made:

If you are using Visual Studio and MSBuild there’s however a very simple workaround to completely exclude some TypeScript files from being compiled.

The solution is to use MSBuild Conditions and/or MSBuild Conditional Constructs, it all depends on how complex your conditional logic will be.

In the simplest case you just have to open your .csproj (or .vbproj) file in a text editor and add the proper Condition attribute to the TypeScriptCompile entry; something like:

<TypeScriptCompile Condition="'$(CONFIG)'=='DEBUG'" Include="UiComponentFeature\UiComponent.ts" />;

With code like this we will compile that TypeScript file only if the DEBUG symbol has been defined for the current build configuration; that’s all we really need to do!

cya next