Introduction to TypeScript
Learn what TypeScript is, who created it and why, its core philosophy, and write your first line of TypeScript code.
Introduction
TypeScript is an open-source programming language, developed and maintained by Microsoft, that adds static types on top of JavaScript. Every valid JavaScript program is already valid TypeScript — TypeScript is a strict superset, meaning it does not replace JavaScript, it extends it with an optional type system layered on top.
This lesson introduces what TypeScript is, why Microsoft built it, the philosophy that shapes every design decision in the language, and gives you your very first taste of actual TypeScript code.
- What TypeScript is and how it relates to JavaScript (a typed superset that compiles down to plain JS).
- Who created TypeScript at Microsoft, and the problems that led to it.
- The core philosophy of gradual, structural typing that guides TypeScript's design.
- The key features that make TypeScript stand out for large codebases.
- What a minimal TypeScript program looks like.
What is TypeScript?
TypeScript is a statically typed, compiled superset of JavaScript. "Statically typed" means you can describe the shape and type of your variables, function parameters, and return values, and the TypeScript compiler checks that everything lines up correctly before your code ever runs. "Compiled" — more accurately "transpiled" — means TypeScript source code (.ts files) is translated into plain JavaScript (.js files) that any browser or Node.js runtime can execute directly, since neither browsers nor Node understand TypeScript syntax natively.
Crucially, TypeScript's type system is entirely a compile-time construct. Once your code is compiled, every type annotation, interface, and generic is stripped away — the output is ordinary JavaScript with zero runtime overhead or extra libraries required. If you already know JavaScript, you already know most of TypeScript; you are simply learning to describe the shapes your data already has.
Who Created TypeScript, and Why
TypeScript was created at Microsoft under the leadership of Anders Hejlsberg, a veteran language designer whose earlier work includes Turbo Pascal, Delphi, and C#. Development began internally around 2010, and TypeScript was publicly announced and open-sourced on October 1, 2012.
Microsoft's own engineering teams were running into the limits of plain JavaScript as their applications grew. JavaScript is dynamically typed by design — a variable can hold any type of value at any time, and that flexibility is wonderful for small scripts but becomes a liability once a codebase reaches hundreds of thousands of lines, maintained by large teams. Typos in property names, functions called with the wrong argument types, and objects missing expected fields were all bugs that JavaScript could only catch at runtime, often in production. TypeScript was designed to catch that entire category of mistakes at compile time instead.
The Problem TypeScript Was Built to Solve
As JavaScript applications grew from small scripts into full single-page applications and large Node.js backends, teams found that the language's dynamic nature — a strength for quick prototyping — became a real cost at scale. Without types, editors could not reliably autocomplete object properties, "rename symbol" refactors were dangerous because the tool could not know every place a property was used, and a huge share of bugs were simple things like calling `.toUpperCase()` on a value that turned out to be a number.
TypeScript's creators set out to keep everything that made JavaScript productive — no build step required to get started, the same runtime semantics, access to the entire npm ecosystem — while adding an optional type layer that IDEs and the compiler could use to catch mistakes before code ever ran, and to power much richer autocomplete, navigation, and refactoring tools.
Core Philosophy
Every feature TypeScript has — and the careful way it stays compatible with JavaScript — traces back to a small set of guiding principles.
- JavaScript compatibility above all — any valid JavaScript file is already valid TypeScript; adoption can be gradual, file by file.
- Types are optional and erased — you opt into as much or as little type-checking as you want, and none of it survives into the compiled output.
- Structural typing over nominal typing — TypeScript compares the *shape* of two types, not their declared names, much like JavaScript's own "duck typing" instincts.
- Stay close to evolving JavaScript — TypeScript tracks TC39 (the committee that standardizes JavaScript) closely and often supports new JS syntax early.
- Represent, don't invent — TypeScript aims to describe the JavaScript patterns developers already use, rather than force a different style of programming onto them.
Key Features at a Glance
Static Typing
Catch type mismatches, typos, and missing properties at compile time instead of at runtime.
Type Inference
TypeScript figures out most types automatically from context — you rarely have to annotate everything.
Structural Typing
Compatibility is based on shape, not on explicitly declared inheritance or naming.
Superset of JavaScript
Every .js file can be renamed to .ts and is already valid — adoption is fully gradual.
Compiles to Plain JS
Ships as ordinary, dependency-free JavaScript that runs anywhere JS already runs.
Rich Editor Tooling
Powers autocomplete, inline errors, safe renames, and "go to definition" in editors like VS Code.
Your First Taste of TypeScript
No introduction to a language is complete without seeing actual code. Here is a small TypeScript function with type annotations on its parameter and return value.
function greet(name: string): string { return `Hello, ${name}!`;}
console.log(greet("TypeScript"));Click Run to see what this code prints.
The `: string` after `name` and after the closing parenthesis are type annotations — they tell TypeScript that `name` must be a string, and that `greet` must return a string. Try calling `greet(42)` and the compiler will refuse to compile, catching the mistake before the code ever runs. Once compiled, the output JavaScript looks almost identical, just without the annotations — they are only for the compiler's benefit.
Where TypeScript Is Used Today
TypeScript has become the default choice for serious frontend and Node.js backend development. Many of the tools and frameworks developers use every day are themselves written in TypeScript.
| Project | What It Is |
|---|---|
| Angular | A major frontend framework built in and designed specifically around TypeScript. |
| Visual Studio Code | Microsoft's hugely popular code editor, itself written largely in TypeScript. |
| Next.js | The leading React framework, with first-class built-in TypeScript support. |
| Deno | A secure JavaScript/TypeScript runtime with TypeScript support built in, no setup required. |
| NestJS | A popular Node.js backend framework designed TypeScript-first from the ground up. |
Common Mistakes
- Assuming TypeScript is a completely different language from JavaScript — it is a superset; every JS file is already legal TS.
- Believing types exist at runtime — they are fully erased during compilation and cannot be inspected once your program is running.
- Thinking you must learn TypeScript instead of JavaScript — you need to know JavaScript first; TypeScript builds directly on top of it.
- Expecting the browser or Node.js to run .ts files directly — TypeScript must always be compiled (or transpiled by a bundler) to plain JavaScript first.
Best Practices
- Make sure you're comfortable with core JavaScript first — TypeScript adds a type layer, it does not replace the language fundamentals.
- Get comfortable reading compiler error messages early; they get much easier to parse with practice.
- Install an editor with strong TypeScript support (VS Code has it built in) so you see errors as you type, not just at compile time.
- When stuck, check the official documentation at typescriptlang.org — it has an excellent interactive playground for experimenting.
Frequently Asked Questions
No. TypeScript is a superset of JavaScript — every valid JavaScript program is already valid TypeScript. It adds an optional type system on top, nothing more.
Yes. TypeScript assumes you already know JavaScript's syntax and behavior; it teaches you how to describe types on top of code you'd otherwise write in plain JS.
No. TypeScript must always be compiled down to plain JavaScript first, either with the tsc compiler or a bundler/tool that transpiles it for you.
Yes. TypeScript is open source under the Apache 2.0 license and is developed publicly on GitHub, led by Microsoft.
Key Takeaways
- TypeScript is an open-source, statically typed superset of JavaScript created by Microsoft.
- It was designed by Anders Hejlsberg's team, first released publicly in October 2012.
- TypeScript's core philosophy is JavaScript compatibility, optional and erased types, and structural typing.
- A minimal TypeScript program looks almost identical to JavaScript, just with optional type annotations.
- TypeScript powers major tools like Angular, VS Code, Next.js, and Deno.
Summary
You now know what TypeScript is, who built it, why it exists, and what its guiding philosophy is. You have also seen your very first line of runnable TypeScript code. Next, you will dig deeper into TypeScript's history — from Microsoft's early internal work through the major version milestones that shaped the language you'll be learning.