export type JSONState = { [key: string]: string | boolean | number | JSONState | Array } export function isJSONState(what: any): what is JSONState { try { JSON.stringify(what) return true } catch (e) { return false } } export interface Rehydratable { dehydrate(): Promise rehydrate(state: JSONState): void | Promise }