pavels555
TTCTheo's Typesafe Cult
•Created by pavels555 on 7/11/2024 in #questions
Types union and how to distinguish them?
doing so I can check later if kind === EventType.Click, and typescript will know that inside that block the object is ClickEvent.
Is that a good approach to this?
Also, could I use instead of
kind: 'click';
the actual type value? EventType.Click
?
What do you think of enums? Should I have created it as enums instaed of const object?
Thanks alot!
3 replies