# TypeScript

> JavaScript with types added. It catches lots of mistakes before the code runs.

**Field:** Software Development  
**Category:** Languages  
**Also known as:** TS

## Think of it like

Think of it like labels on kitchen jars. The labels stop you putting salt in the sugar jar.

## Definition

TypeScript is JavaScript with types added. You can say a value must be a number, a string or a certain shape of object. A checker reads the code and warns you before it runs if a type is wrong. A tool then turns it into plain JavaScript, so it runs anywhere JavaScript does. It came out in 2012, and many big web apps now use it.

## Example

Microsoft made TypeScript, and its VS Code editor is written in it. Jack types "twelve" where a number goes, and the line turns red.

## Example code

```typescript
let age: number = "twelve";
// error TS2322: Type 'string' is not assignable to type 'number'.
```

The checker stops the wrong kind of value before the code runs.

## Why it matters

Big JavaScript projects get hard to change safely. Types let the editor point out what a change will break.

## Common mistake

Thinking TypeScript checks values while the app runs. The checks happen before; at run time it is plain JavaScript.

## Three principles

- **JavaScript plus types.** Every JavaScript file is almost valid TypeScript.
- **Checked early.** Mistakes show up as you type.
- **Runs as JavaScript.** A tool strips the types away.

## Related terms

- [JavaScript](https://learn.benibix.com/term/development/javascript)
- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Compiled Language](https://learn.benibix.com/term/development/compiled-language)
- [Programming Language](https://learn.benibix.com/term/development/programming-language)

## Told apart from

- [JavaScript vs TypeScript](https://learn.benibix.com/compare/javascript-vs-typescript): TypeScript is JavaScript with types added. The types are checked before the code runs, then they are taken away.

## Taught in

- [JavaScript and TypeScript](https://learn.benibix.com/learn/development-languages/javascript-and-typescript): Programming Languages, 5/12

---

Source: https://learn.benibix.com/term/development/typescript
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
