@@ -40,37 +40,47 @@ export {
4040 setFeatureState ,
4141 loadInitialFeatures ,
4242}
43- import type { MiddlewareAPI , Reducer , Middleware , ActionCreator } from 'redux'
44- export type ActionCreators < K extends string | number | symbol , A > = Partial <
45- Record < K , ActionCreator < A > >
46- >
47- export interface CreateReducer < S > {
48- (
49- initialState : S ,
50- reducers : {
51- [ actionType : string ] : Reducer < S >
52- }
53- ) : Reducer < S >
54- ( reducers : { [ actionType : string ] : Reducer < S > } ) : Reducer < S >
43+ import type {
44+ MiddlewareAPI ,
45+ Reducer ,
46+ Middleware ,
47+ AnyAction ,
48+ Dispatch ,
49+ } from 'redux'
50+
51+ export interface CreateReducer < S , A extends AnyAction = AnyAction > {
52+ ( initialState : S , reducers : Record < A [ 'type' ] , Reducer < S , A > > ) : Reducer < S >
53+ ( reducers : Record < A [ 'type' ] , Reducer < S , A > > ) : Reducer < S >
5554}
56- export type ComposeReducers < S > = ( ...reducers : Array < Reducer < S > > ) => Reducer < S >
57- export type ComposeMiddleware = (
58- ...middlewares : Array < Middleware >
59- ) => Middleware
55+ export type ComposeReducers < S , A extends AnyAction = AnyAction > = (
56+ ...reducers : Array < Reducer < S , A > >
57+ ) => Reducer < S , A >
58+ export type ComposeMiddleware <
59+ DispatchExt = { } ,
60+ S = any ,
61+ D extends Dispatch = Dispatch
62+ > = (
63+ ...middlewares : Array < Middleware < DispatchExt , S , D > >
64+ ) => Middleware < DispatchExt , S , D >
6065export type FeatureState = 'NOT_LOADED' | 'LOADING' | 'LOADED' | Error
61- export type FeatureStates = {
62- [ featureId : string ] : FeatureState
63- }
64- export type Feature < S > = {
65- init ?: ( store : MiddlewareAPI < S > ) => any
66- load ?: ( store : MiddlewareAPI < S > ) => Promise < Feature < S > >
66+ export type FeatureStates = Record < string , FeatureState >
67+ export type Feature <
68+ S = any ,
69+ A extends AnyAction = AnyAction ,
70+ D extends Dispatch = Dispatch < A >
71+ > = {
72+ init ?: ( store : MiddlewareAPI < D , S > ) => any
73+ load ?: ( store : MiddlewareAPI < D , S > ) => Promise < Feature < S , A > >
6774 dependencies ?: Array < string >
68- middleware ?: Middleware
69- reducer ?: Reducer < S >
70- }
71- export type Features < S > = {
72- [ featureId : string ] : Feature < S >
75+ middleware ?: Middleware < any , S , D >
76+ reducer ?: Reducer < S , A >
7377}
78+ export type Features <
79+ S ,
80+ A extends AnyAction = AnyAction ,
81+ D extends Dispatch = Dispatch < A >
82+ > = Record < string , Feature < S , A , D > >
83+
7484export type FeatureAction = {
7585 type : string
7686 payload ?: any
0 commit comments