Before we start explaining What is Tyscript? we must first talk about JavaScript . This is a very popular programming language in recent years, and it can be used in frontend and backend, this is possible due to tools and frameworks such as Node.js and Deno that allow creating more advanced and complex systems.
JavaScript was not created for such complex systems. That's why TypeScript was born about 8 years ago, as part of a solution for the modern web that allows you to add JavaScript code types.
JavaScript was a language that presented some problems for large code bases, large-scale applications or projects with a long development time. Therefore, in 2012 Microsoft decided to launch a tool that would help solve all those problems that JavaScript had.
This is how Tyscript was born. Its base is JavaScript with a series of features that gave way to the creation of this option to solve many of the problems that JavaScript has. It focuses on platforms or large-scale developments, for example it was used for Bing, the second most used search engine after Google, and also to develop Office 365.
Below we will review some of the basic features of TypeScript , what it is used for, and how it can differ from JavaScript.
What is TypeScript?
TypeScript is a free and open source programming language developed by Microsoft in mid-2012. It is a very popular language and is one of the most widely used languages in the world.
It is a programming language that allows you to maintain the positive aspects of JavaScript and correct many of the limitations of this language. We can therefore say that it is an improved version of JavaScript.
It does not mean that this is a replacement, but rather that it complements it, and allows you to work from new code, but with the language we know as JavaScript.
Some features of TypeScript:
It is considered a superset of JavaScript, essentially adding static typing and class-based objects.
1. Static typing
Typing refers to how variables are typed, instead Typescript adds static typing, as opposed to JavaScript's dynamic typing, to try to solve a number of problems.
What this means is that TypeScript uses static typing, which allows the variable to be known at compile time, but in the dynamically typed JavaScript language, the type of the variable is known only when the program is executed.
Static typing has the advantage of avoiding hidden errors, refactoring code without side effects, and positioning you correctly in large complex systems.
2. Detect errors in time
This language allows errors to be found while the code is running, meaning that it is not necessary to run the code to notice the error.
3. Interfaces
It allows the use of interfaces, which are a type of construct of the object-oriented language.
4. Classes
Classes allow you to organize things, unlike JavaScript, which is not one of its strong points. They are therefore small containers containing fields, constructors, properties and functions.
5. Intuitive language
It is an easy language to learn, it is easy to read and write, especially if you know JavaScript you can learn.
Why use TypeScript?
✔ TypeScript code is more reliable and simpler to refactor.
✔ It has greater interchangeability, can be used in all libraries.
✔ Explicit types that allow you to focus your attention on how they are distributed in your systems and how the other parts interact.
✔ It is easy to learn, but requires knowledge of JavaScript, so it is not a programming language for beginners.
✔ It allows you to develop without worrying about support for certain new features that are incorporated into different versions of ECMAScript, since the code is then translated to work with older versions.
✔ Improves contextual help while writing code, as it is richer in information than JavaScript.
✔ It allows you to create standard codes for the entire work team, reducing the margins of error and allowing it to grow in the future.
✔ Works well with the Front-End libraries and frameworks you are using.
FREE DOWNLOAD
If you want to know more, download our free JavaScript Fundamentals Ebook and enjoy learning with all the information we have for you. Learn how to create dynamic and interactive web pages.
Why not use TypeScript?
✔ TypeScript is based on large projects, if you are developing small projects or prototypes it may not be a good idea, because you will need to invest more time in adding explicit types.
✔ TypeScript has a steeper learning curve than JavaScript. It's not particularly complex, but it's certainly not like a normal scripting language.
✔ Somewhat complicated type system. Precisely its main advantage, strong typing, is also a source of frustration since if you want to get the most out of it, it forces you to write down the types everywhere (it can be tedious) and it takes away from the undeniable flexibility that JavaScript's weak types have.
✔ Must be compiled. TypeScript is not a language directly supported by browsers and therefore must be compiled to regular JavaScript/ECMAScript before deploying.
Conclusions
TypeScript is a language that has gained prominence in recent years, thanks to its ease of use and ability to alleviate many problems that arise in programming. It is one of the most widely used languages in the world, and web applications can be created from it without having to worry about downloading frameworks or keeping the latest libraries updated on the PC.
It is a very useful tool that you should take into account depending on the real needs of your project. Do you use TypeScript in your projects? How has your experience been?
Courses that may interest you
Do you want to acquire more skills in the JavaScript programming language? We recommend our courses Python from Zero to Expert, Introduction to Web Development and Business Analysis with Excel and Python so you can get the most out of this powerful tool.
