Angular 2

What is Typings in Angular 2 ? [Dynamic vs. Static Typing]

What is Typings in Angular 2?

“Typings is the simple way to manage and install TypeScript definitions.”


“The typings are managed by a type definition package manager called typings”.

1.      Typings allows the TypeScript compiler to use existing classes, properties, and so on…
2.      We can also install typings from a repository using the typings command.
3.      In the third-party libraries, does not ship with their own type definitions. The typings package manager is used to install those type definitions into project.

To define a typings file as,

export declare class User {
    UserName: String;
    constructor(UserName?: String);

Two Types of typing,
1.      Static typing
2.      Dynamic typing

Angular 2 Dynamic vs. Static Typing :-

Angular 2 applications can be written both in Typescript and in plain old JavaScript. This means we have an important choice to make: whether to go with static typing or choose the dynamically typed path.

What’s the difference between statically and dynamically typed languages?

Static Typing:-

Static typing requires that all variables and function return values be typed and TypeScript is an examples of statically typed languages.

For example as,

public sumOfTwoNumbers(num1: number, num2: number): number{
    return num1 + num2;

This “sumOfTwoNumbers()” function takes two numeric (or int) values as arguments and returns a number.

Dynamically Typing :-

Dynamically typing does not require explicit type declaration. Python and JavaScript are best examples of dynamically typed languages.

The above example looks like as,

public sumOfTwoNumbers(num1, num2){
    return num1 + num2;

After calling this method “sumOfTwoNumbers(12, "34");” The output is 1234. There is "No error", "No warning" and nothing else.

I hope you are enjoying with this post! Please share with you friends. Thank you!!

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog -
My Books - Book 1 and Book 2

What is Typings in Angular 2 ? [Dynamic vs. Static Typing] What is Typings in Angular 2 ? [Dynamic vs. Static Typing] Reviewed by Anil Singh on 1:49 AM Rating: (5) Powered by Blogger.