We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2da5f0d commit fcc85d9Copy full SHA for fcc85d9
packages/toolkit/src/tests/combineSlices.test-d.ts
@@ -186,4 +186,21 @@ describe('type tests', () => {
186
(rootState: RootState, num: number) => rootState.inner,
187
)
188
})
189
+
190
+ test('correct type of state is inferred when not declared via `withLazyLoadedSlices`', () => {
191
+ // Related to https://github.com/reduxjs/redux-toolkit/issues/4171
192
193
+ const combinedReducer = combineSlices(stringSlice)
194
195
+ const withNumber = combinedReducer.inject(numberSlice)
196
197
+ expectTypeOf(withNumber).returns.toEqualTypeOf<{
198
+ string: string
199
+ number: number
200
+ }>()
201
202
+ expectTypeOf(withNumber(undefined, { type: '' }).number).toMatchTypeOf<
203
+ number | undefined
204
+ >()
205
+ })
206
0 commit comments