2

I want to type status with FetchingStatus type. How to implement that?

type FetchingStatus = 'idle' | 'loading' | 'succeeded' | 'failed';

const initialState = companyPagesAdapter.getInitialState({
        status: 'idle',
        perPage: 1,
        lastPage: 1
    });

here is signature of getInitialState:

getInitialState<S extends object>(state: S): EntityState<T> & S
Dima Kambalin
  • 283
  • 2
  • 12

1 Answers1

0
type FetchingStatus = "idle" | "loading" | "succeeded" | "failed";
    
    
interface ExtendedEntityAdapterState {
    status: FetchingStatus
    perPage: number,
    lastPage: number
}

const initialState: ExtendedEntityAdapterState   = {
  status: 'idle',
  perPage: 1,
  lastPage: 1
});

companyPagesAdapter.getInitialState(initialState)

Something like this worked for me. Reducer action gives correct constraints.