Skip to content

You are viewing a free preview of this lesson.

Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.

What is TypeScript?

What is TypeScript?

TypeScript is a strongly-typed programming language that builds on JavaScript by adding optional static types. Developed and maintained by Microsoft, TypeScript compiles down to plain JavaScript, meaning it runs anywhere JavaScript runs — in the browser, on Node.js, or in any JavaScript runtime.

The Problem TypeScript Solves

JavaScript is a dynamically typed language. While this flexibility is powerful, it also means many bugs only surface at runtime, often in production. Consider a function that expects a number but receives a string — JavaScript will silently coerce the value, potentially producing incorrect results.

TypeScript catches these mistakes at compile time, before the code ever runs.

function add(a: number, b: number): number {
  return a + b;
}

add(1, 2);       // OK: returns 3
add("1", "2");   // Error: Argument of type 'string' is not assignable to parameter of type 'number'

TypeScript Is a Superset of JavaScript

Every valid JavaScript program is also valid TypeScript. You can rename any .js file to .ts and TypeScript will accept it. From there you can gradually add type annotations to improve safety and tooling support.

This makes TypeScript easy to adopt incrementally — you do not need to rewrite your entire codebase at once.

How TypeScript Works

TypeScript introduces a compilation step. You write .ts files, run the TypeScript compiler (tsc), and it outputs .js files. The type annotations are erased during compilation — they exist purely to help you as a developer and do not affect runtime behaviour.

// TypeScript source (greeter.ts)
function greet(name: string): string {
  return `Hello, ${name}!`;
}

// Compiled JavaScript output (greeter.js)
function greet(name) {
  return `Hello, ${name}!`;
}

Key Benefits of TypeScript

Static type checking catches bugs before runtime. Better IDE support — editors like VS Code provide autocompletion, inline documentation, and refactoring tools that rely on type information. Self-documenting code — type annotations make the expected shape of data explicit, making large codebases easier to navigate and maintain. Safer refactoring — when you rename a function or change a parameter type, TypeScript reports every location that needs updating.

Who Uses TypeScript?

TypeScript has been widely adopted across the industry. Major projects built with TypeScript include Angular, the VS Code editor itself, NestJS, and many libraries in the React and Node.js ecosystems. Surveys consistently show TypeScript as one of the most loved and widely used languages.

TypeScript vs JavaScript

Feature JavaScript TypeScript
Types Dynamic (runtime) Static (compile time)
Compilation None required Compiled to JS
IDE support Good Excellent
Error detection Runtime Compile time
Learning curve Lower Slightly higher

In this course you will learn TypeScript from the ground up, starting with basic types and building up to generics, advanced type features, and tooling configuration.