Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Infer the return type of a promise.
type Await<T extends (...args: any) => any> = T extends (
...args: any
) => Promise<infer U>
? U
: T extends (...args: any) => infer U
? U
: any;
async function load() {
return fetch("...");
}
type Thing = Await<typeof load>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment