TypeScript

TypeScript

TypeScript is a programming language that builds on JavaScript and additionally specifies which kind of data is allowed at which point. This means many errors are caught while the program is being written rather than only when it is run.

Almost every website contains small programs that run in the browser. They make a menu unfold, a shopping cart update, or a map move around. These programs are usually written in the language JavaScript. TypeScript is an extension of exactly this language: you write almost the same thing, but additionally specify what kind of information is allowed to appear at which point. For example, you specify that a particular field holds a number and not text. TypeScript has been developed at Microsoft since 2012, and it is free for anyone to use.

Why developers voluntarily write more

In JavaScript, a variable may contain a number today and a piece of text ten lines later. That’s convenient, but dangerous. If a program tries to divide the text “twenty-three” by two, it only notices this at the moment it is run. For the user, the page suddenly breaks. Such errors are hard to find because the cause is often located at a completely different point in the code.

TypeScript moves this moment forward. The error already becomes visible while the developer is typing, usually as a red underline in the editor. Studies and experience reports from large companies cite figures of around 15 percent of all bugs that can be avoided this way. The price for this is somewhat more writing effort and a steeper learning curve at the start.

A second advantage shows up in large projects. When a hundred people are working on a piece of software, no one can remember by heart what a function written by someone else expects. Type annotations then act like a binding instruction manual that is always up to date. For a small script of 30 lines, on the other hand, this effort is hardly worth it.

From type checking to finished JavaScript

Browsers do not understand TypeScript. That’s why there is a helper program, the so-called compiler. It reads the TypeScript code, checks all type annotations for contradictions, and then writes out ordinary JavaScript. The type annotations themselves are simply removed in the process. The result is that, in the end, perfectly normal JavaScript runs, just as every browser has understood for years.

The consequence of this is important: the check only happens before the program starts, not while it is running. A common misconception is that TypeScript makes a running program safer. If a remote server sends unexpected data, the program can still crash. TypeScript protects against contradictions in one’s own code, not against the outside world.

You don’t have to write down many types yourself. If the code contains the line “let age = 15”, TypeScript automatically infers a number. This guessing is called type inference. You add annotations mainly where data moves between different parts of the program.

TypeScript in apps, job postings, and AI tools

Anyone using a modern web app is very likely using TypeScript code without noticing. Slack, Airbnb, and the coding interface Visual Studio Code are well-known examples. The widely used web frameworks such as React, Angular, or Vue also rely heavily on it. In surveys among developers, TypeScript has ranked among the most-used languages for years.

In job postings, the term almost always appears together with JavaScript. That’s no coincidence, since both belong to the same language family. Anyone who knows JavaScript usually needs only a few days to make the switch. Every JavaScript file is technically already valid TypeScript, so you can migrate step by step.

The language also plays a role with AI tools. Assistants that suggest code often deliver more useful results with TypeScript. The reason is simple: the type annotations additionally tell the model what kind of data is actually meant. Conversely, a made-up suggestion is noticed more quickly, because the compiler immediately flags it as incorrect.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.