How can I combine the following type definitions, so I dont have to repeat myself?
type Lama = {|
name: string,
|};
type LamaWithHat = {|
name: string,
hat: string,
|};
Tried using Interseptions but appearently the syntax might be wrong:
type LamaWithHat = {|
hat: string,
|} & Lama;
How about if we do this /* @flow */
type Lama = {|
name: string,
|};
type LamaWithHat = {|
...Lama,
hat: string,
|};
const a: Lama = {
name: 'rahul'
}
const b: LamaWithHat = {
name: 'rahul',
hat: 'circluar'
}