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.
~ Anders Hejlsberg - Creator of Typescript and C#.
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.
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.
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.
anytype, 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.
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.
- Create a simple generic class.
Now, we create other two class inheriting from the abstract
- Create a concrete class.
Create user class
Create 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?
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.
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.
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.
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.
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.