Documentation
    Preparing search index...

    Type Alias IPropagation<StatusMap, Success>

    IPropagation:
        | {
            [P in keyof StatusMap]: IBranch<
                P extends Success ? true : false,
                P,
                StatusMap[P],
            >
        }[keyof StatusMap]
        | IBranch<false, number, unknown>

    Propagation type.

    IPropagation is a type gathering all possible status codes and their body data types as a discriminated union type. You can specify the status code and its body data type just by using conditional statement like below.

    type Output = IPropagation<{
    200: ISeller.IAuthorized;
    400: TypeGuardError.IProps;
    }>;

    const output: Output = await sdk.sellers.authenticate.join(input);
    if (output.success) {
    // automatically casted to "ISeller.IAuthorized" type
    const authorized: ISeller.IAuthorized = output.data;
    } else if (output.status === 400) {
    // The unknown-status fallback overlaps numeric statuses. Validate the
    // body before treating it as TypeGuardError.IProps.
    const error: unknown = output.data;
    } else {
    // unknown type when out of pre-defined status codes
    const result: unknown = output.data;
    }

    For reference, this IPropagation type is utilized by SDK library generated by @nestia/sdk, when you've configured INestiaConfig.propagate to be true. In that case, SDK functions generated by @nestia/sdk no more returns response DTO typed data directly, but returns this IPropagation typed object instead.

    Type Parameters

    • StatusMap extends { [P in Status]?: any }

      Map of status code and its body data type.

    • Success extends number = 200 | 201

      Default success status code.

    Jeongho Nam - https://github.com/samchon

    contracts/common.md#principled-implementation Each configured status becomes a branch whose success flag is true for configured success statuses, 200 and 201 by default. A false-success fallback with numeric status and unknown data represents unconfigured responses; TypeScript cannot subtract numeric literals from number, so this fallback also overlaps configured failure statuses and status-only narrowing cannot prove their payload shape.

    contracts/common.md#clear-and-simple-design One mapped type indexed into a union, plus the fallback branch.

    contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.

    contracts/common.md#meaningful-documentation The comment gives an example of narrowing and says which generated SDK option uses the type.