#Conditional typing
1 messages · Page 1 of 1 (latest)
use a discriminated union
what if zoom is missing though?
(sidenote; never is different to not being present)
!hb isc
Im just rendering different templates
If zoom is true then renders a wrapper which has options props and if not then im having different thing
The idea was if i pass zoom prop then i get type suggestion for options and if not i would not get them, its totally not necessary but i was just wondering if its possible to make
lmao
bruh what even is this
so if zoom is missing it's also no options?
Well technically yes
I just not sure what way to go
i mean, thats fine too
would be ts type Props = { zoom: true; options: object; } | { zoom?: false; }then
yeah
oh dang
i actually use this pattern for multiple?: false in some react components
never thought about this that way