ReturnType
Like the builtin helper but more convenient to use.
Used with async function
type Shape = {};
async function getShape(): Promise<Shape> {
return {};
}type shape = ReturnType<typeof getShape>;
// ^ shape is Promise<Shape> π€import type { ReturnType } from "tsafe";
type shape = ReturnType<typeof getShape>;
// ^ shape is Shape πUsed with function that can be undefined
undefinedexport type Api = {
getShape?: () => Shape;
};Last updated
Was this helpful?