DEV Community

Cover image for Stop using Javascript
Ivan Zadivar
Ivan Zadivar

Posted on

Stop using Javascript

Hello dear friend. I know that the publication has been entered by title. But before wanting to hit me Hahaha... 😂 What I say is founded, based on work experiences, collaborations, personal projects, etc. And I explained why.

Have you tried refactoring a huge codebase in Javascript? It is literally impossible. Once you reach a certain size it becomes Read-Only. All you can do is add more and more code.
~ Anders Hejlsberg - Creator of Typescript and C#.

Typescript is a Superset of Javascript.

The first point in TypeScript in favor is that Typecript is very similar to Javascript. Since the above part of the Javascript code is tolerable or compatible with Typescript, but Typecript adds certain additional functions. That will be listed bellow.

Explicit language.

One of the best things about Typescript is that it extends Javascript by adding static type to the language. This way I can guarantee that my code meets a goal. By the way The static type is better. The static type force us to defined the data type that will be have the variable. This is very important, for the following reasons. Due to the use of types, we know for sure (as long as we define the types well) what our entities, objects, etc. look like. Something that with Javascript, is impossible, due to its dynamic typing.


At first, it may seem that it complicates things more, but no. This is something valuable, because typescript will not indicate what parameters it receives, if mandatory or optional, and the value it returns. Simply magical.

Detection errors in codification time.

How you can see, Typescript is complaining because the property not specified in the interface. If we are in Javascript would realize until that app execution. Instead in Typescript, the we know beforehand.

Detection Errors

Code autocompletion.

This is a point that nobody touches, and that not have importance in small projects, but if the that have many class, modules, componentes , etc, and that also interact with each other.

Autocompletation Code

How can you visualize Javascritt not autocomplete, and this leads us to look for its definition in our code, go to the Internet to check its values, what it returns, etc. Instead with Typescript we are always documented.

Note: The any type, always must be a temporary wildcard.

Documentation for default. Having with static types, this works as one of the best ways to document your code. The one that is strongly typed implies what we must do always indicate the type of data to work with.

Gradual adoption and easy to learn.

Because typescript uses Javascript syntax, this radically makes adoption easier, because we don't have to start saying, how do you build a function? How do I iterate arrays? among others. On that side we do not have to worry. And the great thing is that now, we can know in advance the type of data we need, and the values it returns. Tell me it's not cool?

❤️ Generic types ❤️

The first thing I want to say is I love Generic Types. The reason why I love you, is because these allow us reuse code. We can understand generics as a kind of code "template", through which we can apply a certain data type to various points in our code. They are used to take advantage of code, without having to duplicate it due to type changes and avoiding the need to use the "any" type.

We make example.

  1. Create a simple generic class.

Generic Class

Now, we create other two class inheriting from the abstract SimpleCRUD class.

  1. Create a concrete class.

Create user class

User Class

Create note class

Note Class

As you may have already realized, you can see how magical generics are. They allow us to abstract functionalities, reuse code, polymorphism, etc. And also, we can add exclusive methods to the concrete classes (UserClass and NoteClass). Do you see why I love them?

High scalability.

The use of static type makes your code much more readable, which makes it easier to understand the legacy code. improving refactoring and error correction times. causing an improvement in the scalability of the code.

Latest features.

It allows you to develop without worrying about the support of certain new features that are incorporated into the different versions of ECMAScript, since the code is then translated to work with older versions.

Integration with any Framework, library or package.

As developers we can see how more tools, frameworks, libraries, packages, etc. They are increasingly adopting Typescript. To such an extent, that it is rare to find a package in npm that does not have a data definition file at least.

Supported by Microsoft and Google.

This is very important to you as a developer. Because the companies that use it, support it, support it, it gives us the assurance that they will not leave it abandoned. And it is always very important to keep this in mind when we integrate technology into our projects.

Poo 🥰

other things that are not mentioned much. Is that Typescript will allow us to work with more Object Oriented thinking. Other things that are not mentioned much. Is that TypeScript will allow us to work with a more Object Oriented thinking. We will be able to work better with classes, use interfaces, handle inheritance, composition, etc.

Design patterns.

Due to the excellent use of OOP, it allows us to use design patterns with greater ease and robustness. It is not that in Javascript they cannot be applied, but that it is too complex due to how little expressive it is. Instead in Typescript, we know which interface to add. By the way, do you want me to make an article with the different design patterns with day-to-day examples? Like and comment.


Promotes more robust and maintainable language to be written. So it is a cleaner language. You can easily write object-oriented code without much knowledge. Refactoring with Typescript tools is much easier and faster. As JavaScript is not a strongly typed language, we tend to work a lot with anonymous objects and that often makes us go blind when we take someone else's project. With TypeScript this stops happening because the data type is validated.

Follow me on social networks.

Discussion (0)