Screenshot of typescript code

Typescript, the open source programming language for JavaScript

At UBIDREAMS, we are committed to developing a corporate culture but above all to sharing our best practices with all employees, presenting new products or even a technology or software that we like to use.

Each employee can make a presentation of their expertise in a field. Today, Clément Moine, a front-end developer who switched to Typescript several months ago, lent himself to the exercise. If, like some of our collaborators, you do not know Typescript or simply want to know more about this language, we invite you to read on.

Ubidreams
Share:
  • You have not accepted cookies to enable this service. You can change your cookies.
  • You have not accepted cookies to enable this service. You can change your cookies.
  • You have not accepted cookies to enable this service. You can change your cookies.

THE WEB DEVELOPMENT ENVIRONMENT

Before even getting into the subject of Typescript, you need to understand how web development works today. The majority of web projects are carried out in Javascript… since browsers only accept this language.

Javascript and in particular the jQuery framework have made it possible to democratize website creation and rendering on small projects. However, if like our company, you have to develop more ambitious projects, the volume of code becomes enormous and complicated to maintain.

JavaScript, although practical, does not present easy to read code. Bug fixes and the evolution of the existing are all the more complicated to implement if the number of files, the number of developers and the complexity of the project are important.

FROM THE IDEA TO THE BIRTH OF TYPESCRIPT

If you have already encountered these problems, rest assured. This is even the main complaint against JavaScript. As early as 2010, Anders Hejlsberg [1], the designer of the .NET framework, decided to facilitate work on large-scale projects. The code needs to be more readable, maintainable and prevent errors.

Typescript was born in 2012 and can be defined as an Open Source programming language called superset (or “superset”) of JavaScript. It therefore includes the syntax of JavaScript and will enrich the language without changing the way it works.

This language will transpile JavaScript code by offering a strongly typed and object-oriented environment thus making it possible to define a framework and enrich the understanding of the code, thus limiting errors.

TypeScript is therefore useful for developers in their development environment since once in production the code is nothing more or less than classic JavaScript.

ADVANTAGES AND DISADVANTAGES OF TYPESCRIPT

If you are not yet convinced to give Typescript a try before finally adopting it, here is a list of some advantages that should tip the scales in favor of the language:

  1. Avoids errors related to the proper character of data (the code will not be transpiled in the event of an error related to incorrect use of typing);

  2. Better organization of the code;

  3. Easier to maintain and upgrade;

  4. Allows you to take good habits by developing;

  5. The technical documentation is very comprehensive.

However, like any language and although Typescript relies on JavaScript, you will have to be particularly vigilant about:

  1. The configuration, in fact, if it is not correctly configured Typescript is very permissive and inefficient;

  2. Typing writing can take a bit of time especially when you are just starting out.

THE FINAL WORD

In conclusion, Typescript can be complex the first days when you start to develop because you will have to put in place new work habits. The progress will however be very fast if one is already used to developing in Javascript.

After a few weeks, you will already be more efficient and organize your code much better.

No more risky function returns where you never really knew what you would get on the output and barely knew the input parameters.

Clément's closing remarks on Typescript: “Personally I have also seen a very nice evolution of Visual Studio Code which is a free IDE created by Microsoft that becomes relatively impressive when coupled with TypeScript. Autocompletion is reinforced and with well-configured linters (TSLint and ESLint for example), we develop so much faster and without errors when the page is loaded that it makes you wonder if returning to pure JavaScript could be possible and would not be. not too painful as the code produced is satisfactory and maintainable. A technology definitely to adopt. ”

WebApplicationReact JS

A question, a project ? We help you define your project.