undefined
}
I'm sure that if yikes_enabled === true then yikes_string won't be undefined
Can I somehow make TS check that? If yes, how to Google it 😵💫
type Foo = | { enabled: true, string: string } | { enabled: false }
Thank you! I have more properties in my actual interface, should I switch whole interface to type? Also when to use type vs interface? I use types mainly for stuff like type Boof = “borf” | “bark” | “woof”
I don't use interface at all. There's nothing interface can do that type can't.
type BorkGoal = { goal_enabled: true, goal_message: string } | { goal_enabled: false } export type Bork = BorkGoal & { id: number username: string Like this?
Обсуждают сегодня