ReturnType

type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;

示例

function getInt(a: string) {
  return parseInt(a);
}

type A = ReturnType<typeof getInt>; // => number

最后更新于