/** data type for user */ export type DataType = T | null /** error type */ export type ErrorType = DataType | Error export enum actionTypeEnum { /** mark before request start status */ REQUEST_INIT = 'REQUEST_INIT', /** mark request success status */ REQUEST_SUCCESS = 'REQUEST_SUCCESS', /** mark request failure status */ REQUEST_FAILURE = 'REQUEST_FAILURE' } /** state */ export interface IState { loading?: boolean; data?: DataType; error?: ErrorType; } /** action */ export interface IAction { type: keyof typeof actionTypeEnum; payload?: DataType; error?: ErrorType; } /** utility type for unpacking a type */ export type Unpacked = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise ? U : T