Skip to content

Commit 108f6b3

Browse files
committed
add type test for overlapping names
1 parent e9e7818 commit 108f6b3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/toolkit/src/tests/createSlice.test-d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,37 @@ describe('type tests', () => {
856856
},
857857
})
858858
})
859+
test('creators can be provided during createSlice call but cannot overlap', () => {
860+
const createAppSlice = buildCreateSlice({
861+
creators: { asyncThunk: asyncThunkCreator },
862+
})
863+
864+
createAppSlice({
865+
name: 'counter',
866+
initialState: 0,
867+
creators: {
868+
something: asyncThunkCreator,
869+
},
870+
reducers: (create) => {
871+
expectTypeOf(create).toHaveProperty('asyncThunk')
872+
expectTypeOf(create).toHaveProperty('something')
873+
return {}
874+
},
875+
})
876+
877+
createAppSlice({
878+
name: 'counter',
879+
initialState: 0,
880+
// @ts-expect-error
881+
creators: {
882+
asyncThunk: asyncThunkCreator,
883+
},
884+
reducers: (create) => {
885+
expectTypeOf(create).toHaveProperty('asyncThunk')
886+
return {}
887+
},
888+
})
889+
})
859890
})
860891

861892
interface Toast {

0 commit comments

Comments
 (0)