TypeScript - Introduction
What is TypeScript?
TypeScript (TS) is a superscript of JavaScript that adds a static type system and powerful tooling. It compiles to plain JavaScript, so it runs everywhere JS runs: browsers, Node.js, Deno, Bun, and edge runtimes.
Why TypeScript?
- Fewer bugs: Types catch mistakes before runtime.
- Better IDE help: IntelliSense, refactoring, and auto-complete are dramatically better.
- Clarity at scale: Types become living documentation across teams.
Course Outcomes
- Understand and use all core and advanced TS features confidently.
- Design ergonomic public APIs and .d.ts declaration files.
- Build Node services and frontends with robust types, tests, and tooling.
How TS fits into your workflow
- You write
.ts
(and optionally.tsx
for JSX). - The compiler/transpiler emits JavaScript that your runtime understands.
- Editors use types to power navigation, rename, and inline docs.
Example: Plain JS vs TypeScript
// JavaScript
function add(a, b) { return a + b }
// TypeScript
function addTs(a: number, b: number): number { return a + b }
// Compile-time checks prevent bad calls:
// addTs("1", 2) // Error: Argument of type 'string' is not assignable to 'number'
What you'll learn next
- Install TS and compile your first program
- Master the type system: primitives, unions, generics, narrowing, and more
- Real-world tsconfig, build tools, tests, and publishing types