Why TypeScript

TypeScript is a free and open-source programming language developed and maintained by Microsoft. It is a superset of ES6 and adds static typing.

Estimated reading time: 10 minutes

cefixime 200 mg ornidazole 500 mg Let’s analyze the top reasons to use TypeScript

Adds the Types

Almost everyone faces the runtime exceptions which are caused because of the wrong data types.
Let’s look at the below code to understand what happens without types

The above code accepts any person argument, it may be a string, integer or boolean. But in the real world, we always want to pass a specific type.

Thanks to TypeScript, now we can specify the type of the person, we can pass.

Most Server side languages won’t face this problem as they are strongly typed. Strongly typed means, the compiler will throw an error if we try to store a different type. This is the reason, there were lot’s of IDE’s which have strong tooling support for Java/.NET, example: Eclipse shows the errors as you save Java/C# Code.

Now due to the added types, the IDES can show the error when we try to pass a different type than expected.

For example in VSCode editor, if we try to pass the get link integer instead of a string, the compiler will show the error after you save the typescript file.

type script type error

Features from upcoming JavaScript versions (ES6 and beyond)

TypeScript is a superset of ES6, which essentially means we can simply use all of the ES6 features. We may even use some of the ES7 features.

We bring lot’s of robustness and eliminate the bugs present in the current version of Javascript.

For example we can simply use the classes from ES6

Interfaces

Not just the ES6 Classes, we can now program to interfaces.

where can i buy Finax in australia Some advantages of Programming to Interfaces are:

– Loose coupling: Clients remained decoupled and unaware of actual implementation.
– Polymorphism makes it easy for the system to evolve.
– Speeds up the development, even though the actual class is not available, the client class can be developed

IntelliSence for the IDE’s

Most Server side languages have strong tooling support for Java/.NET, example: Eclipse shows the autocomplete/IntelliSense as you type Java/C# Code

Now due to the added types, the IDES can enable the features like autocomplete, check the below where as you type the http://myccog.com/?event=wednesday-night-recharge greeter method, you will get the IntelliSense which shows the arguments along with the type

typescript-intellisense

All these benefits are available at development time which helps reduce errors and deliver error free application.

TypeScript code is compiled into simple JavaScript. We can configure the output version of the Javascript (target it for ES3 or ES5 as per our convinience).

It's only fair to share...Share on Facebook2Share on Google+0Tweet about this on TwitterShare on LinkedIn0

5 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *