~/talk

TypeScript Patterns for Better React Components

Talkat Heapcon 2023 · 2023-11-02..11-03· [typescript, react]
slides:none on file

Practical patterns for typing React components with TypeScript: shows how discriminated unions replace multiple boolean props, when to prefer string literals or enums, and how Radix-style slot merging and a strict polymorphic implementation let components accept an as prop safely. Explains augmenting forwardRef to keep generics working, prefers ComponentProps/ComponentPropsWithRef over broad JSX.IntrinsicElements, recommends runtime parsing with Zod instead of any or type assertions, and enables noUncheckedIndexedAccess for safer indexing.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 2:20About the speaker
  3. 3:12History of typing in React
  4. 8:17Boolean props and unions
  5. 11:51Custom components vs variants
  6. 13:35Enhancing components with HTML types
  7. 16:50React.FunctionComponent type
  8. 18:01Reusing types and interfaces
  9. 19:42Compound vs polymorphic components
  10. 23:53React.forwardRef patterns
  11. 25:51React.Context with values
  12. 27:35Overload function components
  13. 28:25Type vs interface comparison
  14. 30:15Type annotations and performance
  15. 30:59Commenting types for productivity
  16. 32:09Avoiding 'any' and runtime parsing
  17. 33:40Tooling for cleaner code
  18. 34:24TypeScript configuration tips
  19. 34:50Purpose of TypeScript types
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.