#Type inference with switch/case
21 messages · Page 1 of 1 (latest)
make it a discriminated union instead of that
Could you elaborate what you mean by that, I'm very basic at TS
!hb discriminated union
sorry i forgot that lol ^
@harsh hornet i'm pretty sure the function doesn't know about the type annotation that's all the way on the other side of the =
you probably want to make the actual function generic
if you want the type ContentFc you'd still be able to do that by doing type ContentFc = typeof Content;
oh right
i forgot that discriminated unions don't need generics
yeah if there are no errors it should be working
yeah typescript automatically narrows discriminated unions (unions with a property that has a different value in different union members)
okey
in your case it's .type
ty you guys for your precious time