~/talk

TypeScript Patterns For Better React Components

Talkat React Brussels 2023 · on Friday, 2023-10-13· [typescript, react]
slides:none on file

Practical TypeScript patterns for React components focus on concrete fixes: prefer string unions over enums because enums add noticeable runtime bundle overhead, use component props / ComponentPropsWithRef for accurate HTML typings, implement compound components by merging props with cloneElement (example: Radix slot), type forwardRef by passing the element through a generic and using the second generic for props (forwardRef generic), treat context as nullable without defaults or wrap it in custom hooks, and validate runtime input with Zod; tools cover roughly 50% of low‑hanging typing work.

AI-written summary · about

  1. 0:00Introduction
  2. 1:02About TypeScript and React
  3. 3:13Boolean props vs union types
  4. 5:03Enhancing components with HTML attributes
  5. 7:28Compound vs polymorphic components
  6. 9:43Forward ref typing
  7. 10:48Typing React context
  8. 12:10Overload function components
  9. 12:53Type vs interface
  10. 15:25Type comments and runtime parsing
  11. 17:09Tools and confidence in TypeScript
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.