guardz-axios
Version:
Type-safe HTTP client built on top of Axios with runtime validation using guardz. Part of the guardz ecosystem for comprehensive TypeScript type safety.
36 lines • 777 B
TypeScript
/**
* Status enum for discriminated union results
*/
export declare enum Status {
SUCCESS = "SUCCESS",
ERROR = "ERROR"
}
/**
* Discriminated union for safe API results
*/
export type SafeResult<T, E = Error> = {
status: Status.SUCCESS;
data: T;
} | {
status: Status.ERROR;
data: E;
};
/**
* Type helper to extract success data type
*/
export type SuccessData<T> = T extends {
status: Status.SUCCESS;
data: infer D;
} ? D : never;
/**
* Type helper to extract error data type
*/
export type ErrorData<T> = T extends {
status: Status.ERROR;
data: infer E;
} ? E : never;
/**
* Type helper for API response results
*/
export type ApiResult<T> = SafeResult<T, import("axios").AxiosError>;
//# sourceMappingURL=status-types.d.ts.map