Please enable Javascript to correctly display the contents on Dot Net Tricks!


Posted On : 03 Mar 2017
Updated On : 03 Mar 2017
Total Views : 719

Data Type

TypeScript is referred to as optional static type language which means you can ask the compiler to ignore the type of a variable if you want to take the advantage of dynamic type. This mixing of static and dynamic typing is also available in C# where you can define the static typed using primary datatype and secondary datatype and also you can define the dynamic type using the dynamic keyword.

Here, we will discuss about the TypeScript Types which you can use to write your TypeScript code.

Any Type

The Any type is a supertype of all types which represents any JavaScript value. You can assign any type of value to it. The any keyword is used to define Any type in TypeScript.

The Any type is useful, when we do not know the type of value (which might come from an API or a 3rd party library) and we want to skip the type-checking on compile time.


function ProcessData(x: any, y: any) {
 return x + y;

let result: any;
result = ProcessData("Hello ", "Any!"); //Hello Any!
result = ProcessData(2, 3); //5

The compiled JavaScript (ES5) code for the above TypeScript code is give below:

function ProcessData(x, y) {
 return x + y;
var result;
result = ProcessData("Hello ", "Any!"); //Hello Any!
result = ProcessData(2, 3);
What do you think?

I hope you will enjoy the Data Type in TypeScript while developing your web app. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.