Concept
A generic function or type takes a type as a parameter, so one definition works for many types without losing track of which one. The caller usually never writes the parameter; it is inferred.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Type parameters doing its job.
function first<T>(items: T[]): T | undefined {
return items[0];
}
const n = first([1, 2, 3]); // number | undefined
const s = first(["a", "b"]); // string | undefined
type ApiResponse<T> = { ok: true; data: T } | { ok: false; error: string };Adding a type parameter that is used only once, such as function log<T>(value: T): void. It constrains nothing and could be unknown; a generic earns its keep by linking two places.
Your roadmap puts these before Type parameters, unless you already know them.
Once a session shows you understand Type parameters, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Type parameters.