我想用FetchingStatus类型键入状态。如何实现?
type FetchingStatus = 'idle' | 'loading' | 'succeeded' | 'failed';
const initialState = companyPagesAdapter.getInitialState({
status: 'idle',
perPage: 1,
lastPage: 1
});
这是getInitialState:的签名
getInitialState<S extends object>(state: S): EntityState<T> & S
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)
这样的事情对我有用。减速器动作提供正确的约束。