如何在合并对象中为createEntityAdapter对象的getInitialState键入属性



我想用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)

这样的事情对我有用。减速器动作提供正确的约束。

相关内容

  • 没有找到相关文章