Or how to combine types.
Interfaces
only support objects
, so if you need to combine other types than objects, you will need types
type Person = {
name: string;
}
type Engineer = {
employer: string;
}
type User = Person & Engineer;
const user: User = {
name: 'Peter',
employer: 'Apple'
}
interface Person {
name: string;
}
interface Engineer {
employer: string;
}
interface User extends Person, Engineer {}
const user: User = {
name: 'Peter',
employer: 'Apple'
}