Skip to content

Module Recap

Module 01 covered the foundation: what TypeScript is, how the compiler works, and how to write and configure a TypeScript project from scratch. Here is what to take forward.

TypeScript adds a type system to JavaScript. Every value has a type, and the compiler verifies that values are used consistently with their types. Errors are reported at compile time — before any code reaches the browser.

The compiler strips types and outputs plain JavaScript. The browser runs .js files. Type annotations, interfaces, and generics do not survive into the output. TypeScript is a development tool, not a runtime feature.

Type annotations describe contracts. Function parameters always need annotations. Return types are worth annotating on public-facing and async functions. Initialized variables and simple return values can be inferred — let TypeScript do the work.

Type inference means less annotation, not less safety. TypeScript infers types from initial values. Writing annotations where TypeScript can already see the type adds noise without adding safety.

tsconfig.json configures the build. strict: true, noEmitOnError, outDir, and lib: ["ES2020", "DOM"] are the settings that matter most for a browser-based project.

AceIt’s tsconfig.json is the configuration you wrote in Lesson 05 — the same file the project uses throughout the course. Every option you set has a reason:

  • strict: true ensures that null and undefined are handled explicitly, and that every parameter has a type — which matters when you are processing API responses that might be missing fields.
  • lib: ["ES2020", "DOM"] makes fetch, document.querySelector, and localStorage available to the type checker.
  • noEmitOnError ensures the dist/ folder only contains code that passed type checking.

In the next module you will add the types that describe AceIt’s data — the shape of a trivia question, the possible difficulty values, the API response from Open Trivia DB. Those types will be checked against the configuration you set up here.

TermWhat it means
Type annotation: string, : number, etc. — a label you add to tell TypeScript what type a value is
Type inferenceTypeScript’s ability to determine a type automatically from context
Compile-time errorAn error the TypeScript compiler reports before code runs
tscThe TypeScript compiler — turns .ts files into .js files
tsconfig.jsonThe project-level configuration file for the TypeScript compiler
strictA compiler flag that enables the full set of type-safety rules
anyA type that disables checking — use sparingly

Module 02 — Core Types →

Module 02 covers the types that describe AceIt’s data: string, number, and boolean primitives; typed arrays; object types; union types for values that can be one of several things; and enums for the fixed set of difficulty levels the app supports.