如何组合 flowjs 类型定义

How to combine flowjs type definitions

如何组合以下类型定义,这样我就不必重复了?

type Lama = {|
name: string,
|};

type LamaWithHat = {|
name: string,
hat: string,
|};

已尝试使用 Interseptions,但语法似乎有误:

type LamaWithHat = {|
hat: string,
|} & Lama;

如果我们这样做怎么样 /* @flow */

type Lama = {|
name: string,
|};

type LamaWithHat = {|
...Lama,
hat: string,
|};

const a: Lama = {
    name: 'rahul'
}

const b: LamaWithHat = {
    name: 'rahul',
    hat: 'circluar'
}

在此处测试此代码 https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgAyAhgLbFgC8YA3gD6oB2ZeAXGAM4YBOAlowHMANKjoBfANzps+ImWIB1XhgAWACWIYqtBgDp9JciJWb2XPoJHipqAMZxGXMMXaGK1GqjDewzUmzAAcm5iFQBXGEDUMXR7Ry0AI1d5JVUNLQ8vHz8A4NCIwJEfMBMMdkDbXm5bGDDibiixIA