Flashcards · TypeScript · Free
TypeScript flashcards, generated for you.
Example TypeScript study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example TypeScript flashcards
What is the difference between 'any' and 'unknown' types in TypeScript?
'any' disables type checking entirely and allows any operation. 'unknown' is type-safe—you must narrow/check the type before using it. Prefer 'unknown' for safer code.
What does the 'as const' assertion do?
'as const' tells TypeScript to treat a value as its literal type rather than its general type. Example: const x = 'hello' as const makes x type 'hello', not string.
What is type narrowing and name two ways to do it.
Type narrowing refines a variable's type within a specific code block. Two methods: (1) typeof guards (typeof x === 'string'), (2) instanceof checks (x instanceof Date).
What's the difference between 'interface' and 'type' for object shapes?
Both define object shapes. Key difference: interfaces can be merged/extended multiple times; types cannot. Interfaces are also slightly better for OOP patterns. Use interfaces by default.
What does 'keyof' do in TypeScript?
'keyof T' produces a union of all property names (keys) of type T as literal string types. Example: keyof {a: 1, b: 2} = 'a' | 'b'.
What's the difference between optional (?:) and nullable (| null | undefined)?
Optional (prop?: string) means the property may not exist. Nullable (prop: string | null) means it exists but may hold null/undefined. They solve different problems.
What is a generic and provide a simple example.
A generic is a type parameter (placeholder) that makes functions/classes work with multiple types. Example: function identity<T>(x: T): T { return x; } uses T as a generic type variable.
Why does 'let x: number = 'hello'' fail but 'const y = 'hello'; const z: any = y; z.toUpperCase()' not cause a compile error?
'any' disables type checking. Once assigned 'any', TypeScript stops validating operations on that variable—this is a gotcha. Avoid 'any'; use 'unknown' or proper types instead.
What is a mapped type and what does 'Readonly<T>' do?
A mapped type transforms an existing type into a new one. Readonly<T> makes all properties of T read-only. Example: Readonly<{a: 1, b: 2}> = {readonly a: 1; readonly b: 2}.
What's the difference between 'void' and 'never' return types?
'void' means a function returns nothing (undefined implicitly). 'never' means a function never returns normally—it throws an error or loops infinitely. Use 'never' for unreachable code or exhaustive checks.
Make your own TypeScript study set
Flashcards for related topics
Studying TypeScript to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →