TypeScript

TypeScript is JavaScript with labels on the data, so a mistake is caught while the code is still being written instead of after it reaches customers.

Also known as TS typed JavaScript JavaScript with types

Definition

TypeScript is JavaScript with labels on the data, so you write the same code but also say what each thing is. A price is a number, a customer has an email address, a booking has a date, and the editor checks every line against those labels while you type. If someone tries to add a price to a name, the mistake is underlined in red before the code has even left the laptop.

It is not a rival to JavaScript but a layer that sits on top of it. Before anything runs, TypeScript strips the labels off and produces ordinary JavaScript, which is what the browser or the server actually runs. Nothing extra is installed on the visitor's phone, and the finished product is not one bit slower. The cost is paid earlier instead, in writing time and in a build step that runs before every release. The language has been around since 2012, and that is long enough that large JavaScript projects are now normally written this way.

Now the part people get wrong. Those checks happen before the code runs, and then they are gone. So when a form is submitted, or another company's system sends you an order, TypeScript is not standing at the door. Whatever arrives, arrives, because calling a field a number does not make it one. The server still has to check incoming data itself, which is why Linkysoft treats that as part of a security review rather than a language choice. Teams who believe the labels are still protecting them while the system runs are the ones who get caught.

Whether it earns its keep depends on size and lifespan, so for one page with one form it is extra work for very little return. For a system with fifty screens, several developers and years ahead of it, it is the difference between renaming a field in ten seconds and searching the whole project by hand. It helps most of all when a website and its mobile app share the same code. That is why Linkysoft writes long-lived web applications in TypeScript and asks one question first. Who will still be working on this in two years? If the honest answer is somebody we have not met yet, the labels are worth every hour they cost.

Questions about TypeScript

Is TypeScript a different language from JavaScript?
Not really. Everything that works in JavaScript works in TypeScript, which only adds the labels. Before it runs, it turns back into plain JavaScript.
Does TypeScript make my website faster?
No. The speed is exactly the same, because the labels are removed before the code runs. What it saves is developer time and mistakes, not milliseconds.
Does TypeScript protect my system from attacks?
No. It catches honest mistakes while the code is written. It does nothing about what a stranger sends your server later, so that check has to be written separately.
Is TypeScript worth it for a small project?
Often not. For a landing page with one form it is mostly extra work. It starts paying off as soon as several people touch the code or the system has to live for years.
Can an existing JavaScript project move to TypeScript?
Yes, file by file. The two live side by side in the same project, so a team usually labels the parts that break most often first and leaves the rest alone.

Still not sure how this applies to your project?

Tell us what you are building and we will answer in plain language.