codejump
Academy

TypeScript

10 pages · about 55 min of reading

  1. 01Type aliases vs interfacesWhat the two actually differ on — declaration merging, unions, and the error messages you get back — and the rule that settles it in a real codebase.
  2. 02Where any, unknown and never belongThe three types that are not about your data: one switches the compiler off, one makes you prove things, and one means this cannot happen.
  3. 03Structural typing: shapes, not namesTypeScript compares shapes, not names. That is why an unrelated object type-checks, why excess properties sometimes error, and how to make a type nothing else can satisfy.
  4. 04Narrowing: how a union becomes one typeThe checks TypeScript understands — typeof, instanceof, in, truthiness, discriminants — and what makes a narrowing silently fall apart again.
  5. 05Literal types, unions and as constWhy a string in a variable stops being a literal, what as const freezes, and why a union of strings beats an enum almost every time.
  6. 06Generics: a type the caller fills inWhat a type parameter actually does, why extends means constrain rather than inherit, and the rule that tells you when a generic is earning its keep.
  7. 07Deriving types with keyof and typeofThe three operators that read types out of things you already wrote, so a type never has to be maintained next to the value it describes.
  8. 08Partial, Pick, Omit and the restPartial, Pick, Omit, Record, Required, Readonly and the rest — what each one is for, which one is unsafe, and how to stop re-declaring the same shape.
  9. 09Mapped and conditional typesHow to write the utility types you have been importing: looping over keys, branching on a type, and pulling a type back out with infer.
  10. 10Type assertions: as vs satisfiesWhat a type assertion actually does to your program, the two places it is defensible, and why satisfies gives you the check without losing the type.