What Is TypeScript? Why TypeScript?
What Is TypeScript? Why TypeScript?
~11 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
Welcome to a complete TypeScript tutorial! Unlike the "React for Professionals" and "React Native for Professionals" series, which only showed TypeScript in COMBINATION with a framework, this one is exclusively about the LANGUAGE itself – every feature, from the ground up, built around its own, continuous example app.
What is TypeScript?
TypeScript is a programming language built by Microsoft that adds strict, optional typing to JavaScript. "Optional", because EVERY valid piece of JavaScript is also valid TypeScript – you can introduce TypeScript gradually, without having to rewrite existing code. "Strict", because once you do use types, TypeScript enforces them CONSISTENTLY: a type error is caught BEFORE running the code, not only at runtime.
No dedicated runtime interpreter: TypeScript compiles to JavaScript
Clearing up a crucial misconception upfront: browsers and Node.js CANNOT run TypeScript code directly. The TypeScript compiler (tsc) translates .ts files into plain JavaScript – all type annotations get stripped ENTIRELY in the process, they only exist at DEVELOPMENT time and have zero effect on the runtime performance or behavior of the executed code.
// What you write (input.ts):
function add(a: number, b: number): number {
return a + b;
}
// What the browser/Node.js actually runs (output.js, after tsc):
function add(a, b) {
return a + b;
}Why types at all? A concrete example
Plain JavaScript allows the following without complaint – until it crashes at runtime, often far away from the actual root cause:
function calculateDiscount(price, percent) {
return price - (price * percent / 100);
}
calculateDiscount(100, '10'); // works "by accident" (string gets coerced)
calculateDiscount('100 dollars', 10); // NaN - no error, but a silent, wrong result
calculateDiscount(100); // NaN - missing parameter, no warningWith TypeScript, EACH of these three calls gets flagged IMMEDIATELY in the editor as an error – BEFORE the first run, not only once a user hits a wrong calculation in production:
function calculateDiscount(price: number, percent: number): number {
return price - (price * percent / 100);
}
calculateDiscount(100, '10'); // Error: Argument of type 'string' is not assignable to 'number'
calculateDiscount('100 dollars', 10); // Error: Argument of type 'string' is not assignable to 'number'
calculateDiscount(100); // Error: Expected 2 arguments, but got 1| Language | When errors surface |
|---|---|
| JavaScript | Type errors show up (if at all) ONLY at RUNTIME – often as undefined is not a function or a silent, wrong result, far from the actual source of the error. |
| TypeScript | Type errors get caught BEFORE running the code, directly in the editor, with the exact line and an explanation – the error is often fixed before the code even runs for the first time. |
Further benefits beyond pure error prevention
- Autocompletion: the editor knows an object's exact shape and only suggests properties/methods that ACTUALLY exist – no guessing which fields an API result really has.
- Self-documenting code: a function signature like
function findBook(isbn: string): Book | undefinedexplains its behavior without needing a comment. - Safer refactoring: rename a property or change a function signature, and TypeScript IMMEDIATELY flags every spot across the whole project that needs updating.
This series' example project: a library management system
Together, we'll build a library management app – a plain command-line program in Node.js/TypeScript, with NO React, NO database, NO web framework. The reason for this deliberately lean choice: you should be able to focus exclusively on the TypeScript LANGUAGE, without being distracted by framework-specific concepts. Managing books, authors, and library members – along the way, we'll experience EVERY important TypeScript feature through a real, growing use case: from simple types through classes and generics to advanced type tricks.
Tipp: Prerequisite: you should already know JavaScript basics (variables, functions, arrays, objects, if/for). TypeScript builds entirely on top of JavaScript – this tutorial explains the TYPING, not JavaScript itself from the ground up.