Skip to content

Commit b6d1d5d

Browse files
committed
fix type portability examples
1 parent 3ec07e9 commit b6d1d5d

File tree

3 files changed

+24
-42
lines changed

3 files changed

+24
-42
lines changed

examples/type-portability/bundler/src/features/polling/pollingSlice.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { PayloadAction } from '@reduxjs/toolkit'
21
import { createSlice } from '@reduxjs/toolkit'
32
import type { RootState } from '../../app/store'
43

@@ -37,27 +36,22 @@ export type PollingAppKey = keyof (typeof initialState)['apps']
3736
export const pollingSlice = createSlice({
3837
name: 'polling',
3938
initialState,
40-
reducers: (creators) => {
39+
reducers: (create) => {
4140
return {
42-
toggleGlobalPolling: creators.reducer((state) => {
41+
toggleGlobalPolling: create.reducer((state) => {
4342
state.enabled = !state.enabled
4443
}),
45-
updatePolling(
46-
state,
47-
{
48-
payload,
49-
}: PayloadAction<{
50-
app: PollingAppKey
51-
enabled?: boolean
52-
interval?: number
53-
}>,
54-
) {
44+
updatePolling: create.reducer<{
45+
app: PollingAppKey
46+
enabled?: boolean
47+
interval?: number
48+
}>((state, { payload }) => {
5549
const { app, ...rest } = payload
5650
state.apps[app] = {
5751
...state.apps[app],
5852
...rest,
5953
}
60-
},
54+
}),
6155
}
6256
},
6357
selectors: {

examples/type-portability/nodenext-cjs/src/features/polling/pollingSlice.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ReduxToolkit = require('@reduxjs/toolkit')
22

3-
import type { PayloadAction } from '@reduxjs/toolkit'
43
import type { RootState } from '../../app/store.js'
54

65
namespace pollingSliceModule {
@@ -41,27 +40,22 @@ namespace pollingSliceModule {
4140
export const pollingSlice = createSlice({
4241
name: 'polling',
4342
initialState,
44-
reducers: (creators) => {
43+
reducers: (create) => {
4544
return {
46-
toggleGlobalPolling: creators.reducer((state) => {
45+
toggleGlobalPolling: create.reducer((state) => {
4746
state.enabled = !state.enabled
4847
}),
49-
updatePolling(
50-
state,
51-
{
52-
payload,
53-
}: PayloadAction<{
54-
app: PollingAppKey
55-
enabled?: boolean
56-
interval?: number
57-
}>,
58-
) {
48+
updatePolling: create.reducer<{
49+
app: PollingAppKey
50+
enabled?: boolean
51+
interval?: number
52+
}>((state, { payload }) => {
5953
const { app, ...rest } = payload
6054
state.apps[app] = {
6155
...state.apps[app],
6256
...rest,
6357
}
64-
},
58+
}),
6559
}
6660
},
6761
selectors: {

examples/type-portability/nodenext-esm/src/features/polling/pollingSlice.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { PayloadAction } from '@reduxjs/toolkit'
21
import { createSlice } from '@reduxjs/toolkit'
32
import type { RootState } from '../../app/store.js'
43

@@ -37,27 +36,22 @@ export type PollingAppKey = keyof (typeof initialState)['apps']
3736
export const pollingSlice = createSlice({
3837
name: 'polling',
3938
initialState,
40-
reducers: (creators) => {
39+
reducers: (create) => {
4140
return {
42-
toggleGlobalPolling: creators.reducer((state) => {
41+
toggleGlobalPolling: create.reducer((state) => {
4342
state.enabled = !state.enabled
4443
}),
45-
updatePolling(
46-
state,
47-
{
48-
payload,
49-
}: PayloadAction<{
50-
app: PollingAppKey
51-
enabled?: boolean
52-
interval?: number
53-
}>,
54-
) {
44+
updatePolling: create.reducer<{
45+
app: PollingAppKey
46+
enabled?: boolean
47+
interval?: number
48+
}>((state, { payload }) => {
5549
const { app, ...rest } = payload
5650
state.apps[app] = {
5751
...state.apps[app],
5852
...rest,
5953
}
60-
},
54+
}),
6155
}
6256
},
6357
selectors: {

0 commit comments

Comments
 (0)