~/talk

React conditional props with Typescript

Talkat React Day Bangalore 2022 · 2022-06-08..06-09· [typescript, react]
links:none on file
slides:none on file

Shows a concrete pattern that uses TypeScript discriminated unions to make a CTA component accept exactly one valid prop set: discriminated unions make href required for the link variant and impossible for button or no-op, and IDE autocomplete plus compile-time errors enforce that. Implementation uses React.ComponentPropsWithoutRef to inherit HTML props, demoed in CodeSandbox, and it works; known tradeoffs: kind must be preserved (or null) and props must be destructured later.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 0:21Talk agenda overview
  3. 1:04Defining the problem with examples
  4. 3:29Solution requirements and goals
  5. 4:32Solution approach and setup
  6. 6:39Implementing discriminated unions
  7. 8:25Live code demonstration
  8. 9:27Additional benefits of the solution
  9. 10:10How type narrowing works
  10. 10:30Current solution limitations
  11. 10:51Related concepts and patterns
  12. 12:59Advanced TypeScript techniques
  13. 13:20Conclusion and further research
~/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.