Skip to content

Pre Processing Macros

Steve4448 edited this page Oct 21, 2014 · 2 revisions

There are a few different preprocessing macros (Statements that are executed before the actual compilation.) that significantly speed up the TypeScript programming process and ease of use if used properly.

@include

The @include file macro allows very easy reference of a file and will include the script at the same time. You can also give a name to the file so that you can access it, @include "file":FriendlyName, allows you to afterwards use FriendlyName.method();


Example:

@include "path/Helper.ts"

Would reference the file "Helper.ts" in the "path" folder and additionally include it at runtime. The output of the example file when pre-processed would look like:

/// <reference path="path/Helper.ts" />
var Helper = _typeinclude("path/Helper.ts");

Which would allow you to now access anything in Helper by simply calling Helper.method();

@reference

To simply reference a file in your script you can use the macro @reference <file>.


Example:

@reference "path/File.ts"

Would reference the file "File.ts" in the "path" folder and additionally include it at runtime. The output of the example file when pre-processed would look like:

/// <reference path="path/File.ts" />
Clone this wiki locally