等价于打字稿中从流传播的类型?

时间:2019-01-23 16:57:20

标签: typescript flowtype

在Flow中,我们可以这样做:

type Props<T> = {
  ...T,
  other: string,
}

打字稿内部是否存在等效内容?我正在尝试将我的代码转换为打字稿,但是像这样的一些基本的东西却让人头疼。在任何地方都找不到与此相关的任何东西。

1 个答案:

答案 0 :(得分:0)

这不完全是您要的,但也许您只是想扩展?

interface A {
  foo: string;
}
interface B extends A {
  bar: number;
}

const x: B = {
  foo: "some",
  bar: 10
};
相关问题