Typescript infer

2020-08-27  本文已影响0人  chenjinchao1997

import { promises } from "fs"

async function asyncFn() {
return 'string';
}
type UnPromisify<T> = T extends Promise<infer U> ? U : never;

// type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
type T2 = ReturnType<typeof asyncFn>;
type T1 = UnPromisify<T2>;
// T1 string

上一篇下一篇

猜你喜欢

热点阅读