Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional compilation in TypeScript

Tags:

typescript

Is there a way to do conditional compilation in TypeScript using #if, #endif directives for example? I wish I was able to enable/disable tracing.

like image 261
Trident D'Gao Avatar asked Feb 24 '14 18:02

Trident D'Gao


People also ask

What statements are used for conditional compilation?

The $ELSE statement is used in conjunction with the $IF statement to control conditional compilation. The $END statement is used in conjunction with the $IF statement to control conditional compilation. A $IF statement provides the means whereby selected parts of the source text are not included in the compilation.

What is conditional compilation in Java?

The conditional compilation practice is used to optionally remove chunks of code from the compiled version of a class. It uses the fact that compilers will ignore any unreachable branches of code. To implement conditional compilation, define a static final boolean value as a non-private member of some class.

What is meant by conditional compilation?

Conditional compilation provides a way of including or omitting selected lines of source code depending on the values of literals specified by the DEFINE directive. In this way, you can create multiple variants of the same program without the need to maintain separate source streams.

How do you add a condition in TypeScript?

Syntax: We can create the conditional types with the used of ternary operator and extends in TypeScript. Type1 extends Type2 ? for One value : for different value; Here extend works as compare function which checks is Type1 have properties of Type2 if yes then it jumps to true branch else in the false branch.


1 Answers

There isn't currently, but vote for the feature request so that it makes it in someday!

like image 159
MgSam Avatar answered Sep 19 '22 18:09

MgSam