@jiminp/tooltool
    Preparing search index...

    Type Alias OptionalIfVoid<T>

    OptionalIfVoid: [T] extends [undefined | void] ? [t?: T] : [T]

    Converts a type into a tuple that is optional when T is void or undefined.

    Designed for use with rest parameters in generic functions, allowing callers to omit the argument entirely when the type indicates no value is expected.

    Type Parameters

    • T

      The type to evaluate for optionality.

    function dispatch<T>(action: string, ...payload: OptionalIfVoid<T>): void {
    // ...
    }

    dispatch<void>('reset'); // ✓ OK — payload omitted
    dispatch<number>('increment', 5); // ✓ OK — payload required
    dispatch<number>('increment'); // ✗ Error — missing argument