Skip to content

Commit 2c4d418

Browse files
authored
Merge pull request #3177 from Methuselah96/redux-alpha-fix-type-errors
2 parents c4d1527 + c00e0b9 commit 2c4d418

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

packages/toolkit/src/tests/configureStore.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('configureStore', async () => {
270270
let dummyEnhancerCalled = false
271271

272272
const dummyEnhancer: StoreEnhancer =
273-
(createStore: StoreEnhancerStoreCreator) =>
273+
(createStore) =>
274274
(reducer, ...args: any[]) => {
275275
dummyEnhancerCalled = true
276276

packages/toolkit/src/tests/configureStore.typetest.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ const _anyMiddleware: any = () => () => () => {}
159159
})
160160

161161
{
162-
type SomePropertyStoreEnhancer = StoreEnhancer<{ someProperty: string }>
163-
164-
const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = (next) => {
162+
const somePropertyStoreEnhancer: StoreEnhancer<{ someProperty: string }> = (
163+
next
164+
) => {
165165
return (reducer, preloadedState) => {
166166
return {
167167
...next(reducer, preloadedState),
@@ -170,13 +170,9 @@ const _anyMiddleware: any = () => () => () => {}
170170
}
171171
}
172172

173-
type AnotherPropertyStoreEnhancer = StoreEnhancer<{
173+
const anotherPropertyStoreEnhancer: StoreEnhancer<{
174174
anotherProperty: number
175-
}>
176-
177-
const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = (
178-
next
179-
) => {
175+
}> = (next) => {
180176
return (reducer, preloadedState) => {
181177
return {
182178
...next(reducer, preloadedState),
@@ -187,7 +183,10 @@ const _anyMiddleware: any = () => () => () => {}
187183

188184
const store = configureStore({
189185
reducer: () => 0,
190-
enhancers: [somePropertyStoreEnhancer, anotherPropertyStoreEnhancer],
186+
enhancers: [
187+
somePropertyStoreEnhancer,
188+
anotherPropertyStoreEnhancer,
189+
] as const,
191190
})
192191

193192
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(

packages/toolkit/src/tsHelpers.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,14 @@ export type ExtractDispatchExtensions<M> = M extends MiddlewareArray<
101101
? ExtractDispatchFromMiddlewareTuple<[...M], {}>
102102
: never
103103

104-
export type ExtractStoreExtensions<E> = E extends any[]
105-
? UnionToIntersection<E[number] extends StoreEnhancer<infer Ext> ? Ext extends {} ? Ext : {} : {}>
104+
export type ExtractStoreExtensions<E> = E extends readonly any[]
105+
? UnionToIntersection<
106+
E[number] extends StoreEnhancer<infer Ext>
107+
? Ext extends {}
108+
? Ext
109+
: {}
110+
: {}
111+
>
106112
: {}
107113

108114
/**

0 commit comments

Comments
 (0)