// https://github.com/microsoft/TypeScript/issues/1897#issuecomment-657294463 // Alteration: Added `undefined` to SerializableScalar to capture behavior of the Object type export type SerializableScalar = string | number | boolean | null | undefined | unknown; export interface SerializableObject { // eslint-disable-next-line no-use-before-define [key: string]: SerializableScalar | SerializableObject | SerializableArray; } export function isSerializableObject(object: unknown): object is SerializableObject { return typeof object === 'object' && !Array.isArray(object) && object !== null; } export type SerializableArray = Array; export type Serializable = SerializableScalar | SerializableObject | SerializableArray; export interface RequestOptions { url: string method?: string envelope?: boolean headers?: Record data?: unknown; } export type RequestHeaders = Record export interface SuccessResponse { ok: true; status: number; response: R; } export interface ErrorResponse { ok: false; status: number; error: unknown; } export type NetworkResponse = SuccessResponse | ErrorResponse