如何使TypeScript将对象类型转换为函数的参数类型?

时间:2020-05-15 09:47:29

标签: typescript

我有一个看起来像这样的对象

type PersonObject = {
  firstName: string;
  lastName: string;
};

我想将PersonObject类型转换为这种类型

type PersonFunction = (firstName: string, lastName: string) => void;

我被卡在转换器部分

type Converter<T> = ?

所以用法变成了

type PersonFunction = Converter<PersonObject>;

我已经尝试过utility-types,但是它没有我想要的实用程序。

如何编写该转换器?

0 个答案:

没有答案