If you discover the arguments for type systems persuasive generally , then you will be proud of TypeScript.It brings many of the advantages of type system (safety,readability, improved tooling) to the JavaScript ecosystem.

It also suffers from a number of the drawbacks of type systems (added complexity and incompleteness).

Safety

TypeScript catches type errors early through static analysis:

function double(x: number): number {
return 2 * x;
}
double('2');
// ~~~ Argument of type '"2"' is not assignable to parameter of type 'number'.

Readability

TypeScript enables editors to provide contextual documentation:

You’ll never forget whether String.prototype.slice takes (start, stop) or (start, length) again!

Tooling

TypeScript allows editors to perform automated refactors which are aware of the rules of the languages

Here, for instance, Visual Studio Code is able to rename references to the inner foo without altering the outer foo.This would be difficult to do with a simple find/replace.

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: Why and when to use TypeScript

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

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories

About

Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password