TypeScript flashcards
JavaScript with a type checker: catch bugs at edit time, model your domain and refactor large codebases safely.
Beginner friendly, starts from zero
0
TypeScript at a glance
TypeScript is JavaScript with labels for each kind of value, plus a checker that catches mistakes before the code runs.
Like labels on kitchen jars: they warn you before you put salt in the tea.
Words you will meet
- Type
- The kind of value something holds, like number or text
- Variable
- A named box that holds a value
- Property
- One named part of an object, like name or age
- Annotation
- A type you write yourself after a colon
- Interface
- A named description of an object's shape
- Union
- A type that allows one of several choices
- Compile
- Turn TypeScript into plain JavaScript by removing the labels
- Runtime
- The moment the code actually runs
The steps
- 1. Start from zero (12 cards): What TypeScript is, the words it uses, and your first type error.
- 2. Core basics (16 cards): Annotations, inference, unions, interfaces and how TypeScript runs in 2026.
- 3. Next steps (16 cards): Narrowing, discriminated unions, generics, utility types, as const and satisfies.
- 4. Go deeper (17 cards): Conditional and mapped types, exhaustiveness, branding, strictness flags, runtime validation and compiler internals.
All 12 cards in Start from zero
- What is TypeScript, in one plain sentence?
- TypeScript is JavaScript with labels that say what kind of value each thing holds, plus a checker that warns you about mistakes before the code runs.
- What went wrong in plain JavaScript before TypeScript?
- A typo like
user.emial, or text sent where a number was needed, showed up only when the page broke for a real user. TypeScript points at it while you type. - Where do you already meet TypeScript in daily life?
- Many big apps and websites you use are written in it, and so are popular code editors. If an editor ever underlined a mistake in red as you typed code, a checker like this was at work.
- What everyday thing is TypeScript like?
- Labels on kitchen jars. If someone reaches for the jar marked 'sugar' to sweeten tea and it is really salt, the label warns him before he spoils the cup.
- What are a 'value', a 'variable' and a 'type'?
- A value is a piece of data, like
42or"Arun". A variable is a named box that holds a value (made withconstorlet), and its type is the kind of value:number,string(text) orboolean(trueorfalse). - What are an 'object', a 'property' and an 'array'?
- An object groups named values, like
{ name: "Arun", age: 12 }; each named part is a property. An array is an ordered list, like[10, 20, 30]. - What are a 'function', a 'parameter' and a 'return value'?
- A function is a named set of steps you can reuse. A parameter is an input it receives, and the return value is what it gives back; code that uses the function is its caller.
- What do 'interface', 'union',
nullandundefinedmean? - An interface is a named description of an object's shape: which properties it has and their types. A union means 'one of these', written with
|, andnullandundefinedboth mean no value. - What do 'compile', 'runtime',
tscand 'bundler' mean? - To compile here is to turn TypeScript into plain JavaScript by removing the labels; runtime is when the code actually runs.
tscis the TypeScript checker, set up bytsconfig.json, and a bundler packs your files for the browser. - What do you need before starting?
- A little JavaScript, a code editor such as VS Code (it understands TypeScript out of the box) and Node.js, which runs JavaScript on your computer.
- Your first tiny win: why is the second line an error?
: numberis a type label, called an annotation:agemust hold a number. Putting text in it makes TypeScript show an error before anything runs.- What will you be able to do after this topic?
- Add types to your JavaScript, describe your data with interfaces and unions, read type errors calmly, and change big code safely.
TypeScript cheatsheet
Everyday types
string[] / readonly T[]Arrays, mutable or notRecord<"a" | "b", V>Object with exactly those keys"draft" | "live"Literal union[lat: number, lng: number]Labelled tupleunknownAnything, must narrow firstneverImpossible value, exhaustiveness(e: Event) => voidFunction type
Utility types
Partial<T> / Required<T>All optional / all requiredPick<T, K> / Omit<T, K>Keep / drop keysReadonly<T>No writes, shallowReturnType<typeof fn>Function result typeParameters<typeof fn>Argument tupleAwaited<T>Unwrap promisesNonNullable<T>RemovenullandundefinedExtract<U, X> / Exclude<U, X>Filter a union
Operators
keyof TUnion of keysT[K]Type at a keytypeof valueType of a variablevalue as constLiteral, readonlyvalue satisfies TCheck, keep inferred typex is TType guard return<const T>Infer literals for a parameter
Type-level patterns
T extends U ? X : YConditional typeinfer RCapture part of a match{ [K in keyof T]: ... }Mapped type[K in keyof T as `get${Capitalize<K & string>}`]Rename keys`${A}:${B}`Template literal typeT & { __brand: "Id" }Branded primitive
tsconfig and CLI
npx tsc --noEmitType check onlynpx tsc -b --incrementalBuild project referencesnpx tsc --extendedDiagnosticsWhere compile time goes"noUncheckedIndexedAccess": trueIndex reads may be undefined"verbatimModuleSyntax": trueRequireimport type"erasableSyntaxOnly": trueOnly strippable syntaxnode app.tsNode 24 strips types and runs