Welcome Guest. Sign in or Signup


Posted on May 3, 2014 1 Comments

Why does the .TS file not convert to .JS while compiling a TypeScript project?

This usually happens because you haven’t marked the TS file’s Build Action as “TypeScriptCompile”. You can do so as follows in the properties window of the TS file: Now build your project and the js file will be generated.

Posted on April 11, 2014 0 Comments

How to type cast in TypeScript?

You can use a “type assertion” expression to do so. A type assertion expression consists of a type enclosed in < and > followed by a unary expression. Type assertion expressions are purely a compile-time construct. Type assertions are not checked at run-time and have no impact on the emitted JavaScript (and therefore no run-time […]

Posted on January 24, 2013 2 Comments

How to extend native JavaScipt object in TypeScript ?

Sometimes we might what to inherit some property from native js function in TS, but in TS each and every JS object will be an interface so we can’t extend that to our own class. We can workaround to extend native JavaScipt object in TypeScript .

Posted on January 2, 2013 0 Comments

How to create instance methods in TS (rather than prototypes)?

If you define a function like this in JS, it would be an instance method: However, when you do the same in TS, compiling it to JS will convert it to a prototype function, which might not be always preferrable. So, to instead prevent the function from becoming a prototype, do this in TS to […]

Posted on December 17, 2012 1 Comments

How to use external js in typescript?

Not everything you reference in your TypeScript code has to be defined in TypeScript itself. You can reference JavaScript code that is defined in some JS file using the “declare” keyword as seen in the example below. Here is the resultant view of sample,