devtypes - v2.0.0
    Preparing search index...

    Type Alias AwaitedReturnType<F>

    AwaitedReturnType: F extends (...args: any[]) => infer R
        ? R extends Promise<infer U> ? U : R
        : never

    Get the awaited return type of a function.

    Type Parameters

    • F

      Function type

    Combines return type extraction with automatic Promise unwrapping. It's come in handy when dealing with async functions.

    type F1 = () => string;
    type R1 = AwaitedReturnType< F1 >; // string
    type F2 = () => Promise< number >;
    type R2 = AwaitedReturnType< F2 >; // number