1 min lesson
TypeScript fluency under time pressure
Compare two rows from "TypeScript fluency under time pressure", then say when each one fits.
Step 1 of 2
TypeScript is the language the editor surface is written in, so fluency is table stakes. Fumbling syntax burns the minutes you need for reasoning and it reads as someone who doesn't write TS daily.
Be reflexively fast with the few constructs editor code leans on. Not exotic type gymnastics - the everyday tools, used cleanly.
- Construct
- Map / Set
- Reach for it when
- Grouping, dedup, counting, adjacency
- One-liner you should know cold
- (m.get(k) ?? []).push(v) for grouped lists
- Construct
- Discriminated union
- Reach for it when
- Modeling a node or result with variants
- One-liner you should know cold
- switch (n.kind) with exhaustive checks
- Construct
- Generics
- Reach for it when
- A reusable helper over any element type
- One-liner you should know cold
- function groupBy<T, K>(xs: T[], key: (x: T) => K)
- Construct
- async / await
- Reach for it when
- File IO, hashing, streamed responses
- One-liner you should know cold
- await Promise.all(paths.map(readFile))
| Construct | Reach for it when | One-liner you should know cold |
|---|---|---|
| Map / Set | Grouping, dedup, counting, adjacency | (m.get(k) ?? []).push(v) for grouped lists |
| Discriminated union | Modeling a node or result with variants | switch (n.kind) with exhaustive checks |
| Generics | A reusable helper over any element type | function groupBy<T, K>(xs: T[], key: (x: T) => K) |
| async / await | File IO, hashing, streamed responses | await Promise.all(paths.map(readFile)) |