type RemoteData = | NotAskedState | LoadingState | SuccessState | ErrorState; export interface LoadingState { readonly state: 'loading'; readonly isLoading: true; readonly value?: T; } export interface SuccessState { readonly state: 'success'; readonly isLoading: false; readonly value: T; } // etc