Interfaces or Type Aliases? Oh, my!
Prologue: Type unions and intersections
type StringOrNumber = string | number
var subject: StringOrNumber
subject = 'hello' // OK
subject = 2 // OK
subject = true // errortype Person = { name: string }
type Callable = { phone: string }
type CallablePerson = Person & Callable
var person: CallablePerson = { name: 'John' } // error, missing "phone"Interfaces or Type Aliases? Oh, my!
Last updated