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!!

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment Powered by Blogger.