Skip to content

Commit 94937b1

Browse files
committed
rename context types
1 parent b05b9a7 commit 94937b1

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packages/toolkit/src/createSlice.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ export type ReducerCreators<
182182
: Name]: SliceReducerCreators<State, any, any>[CreatorMap[Name]]['create']
183183
}
184184

185-
interface ReducerHandlingContext<State> {
185+
interface InternalReducerHandlingContext<State> {
186186
sliceCaseReducersByType: Record<string, CaseReducer<State, any>>
187187
sliceMatchers: ActionMatcherDescriptionCollection<State>
188188

189189
sliceCaseReducersByName: Record<string, any>
190190
actionCreators: Record<string, any>
191191
}
192192

193-
export interface ReducerHandlingContextMethods<State> {
193+
export interface ReducerHandlingContext<State> {
194194
/**
195195
* Adds a case reducer to handle a single action type.
196196
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
@@ -199,7 +199,7 @@ export interface ReducerHandlingContextMethods<State> {
199199
addCase<ActionCreator extends TypedActionCreator<string>>(
200200
actionCreator: ActionCreator,
201201
reducer: CaseReducer<State, ReturnType<ActionCreator>>,
202-
): ReducerHandlingContextMethods<State>
202+
): ReducerHandlingContext<State>
203203
/**
204204
* Adds a case reducer to handle a single action type.
205205
* @param actionCreator - Either a plain action type string, or an action creator generated by [`createAction`](./createAction) that can be used to determine the action type.
@@ -208,7 +208,7 @@ export interface ReducerHandlingContextMethods<State> {
208208
addCase<Type extends string, A extends Action<Type>>(
209209
type: Type,
210210
reducer: CaseReducer<State, A>,
211-
): ReducerHandlingContextMethods<State>
211+
): ReducerHandlingContext<State>
212212

213213
/**
214214
* Allows you to match incoming actions against your own filter function instead of only the `action.type` property.
@@ -224,7 +224,7 @@ export interface ReducerHandlingContextMethods<State> {
224224
addMatcher<A>(
225225
matcher: TypeGuard<A>,
226226
reducer: CaseReducer<State, A extends Action ? A : A & Action>,
227-
): ReducerHandlingContextMethods<State>
227+
): ReducerHandlingContext<State>
228228
/**
229229
* Add an action to be exposed under the final `slice.actions` key.
230230
* @param name The key to be exposed as.
@@ -239,7 +239,7 @@ export interface ReducerHandlingContextMethods<State> {
239239
exposeAction(
240240
name: string,
241241
actionCreator: unknown,
242-
): ReducerHandlingContextMethods<State>
242+
): ReducerHandlingContext<State>
243243
/**
244244
* Add a case reducer to be exposed under the final `slice.caseReducers` key.
245245
* @param name The key to be exposed as.
@@ -254,7 +254,7 @@ export interface ReducerHandlingContextMethods<State> {
254254
exposeCaseReducer(
255255
name: string,
256256
reducer: unknown,
257-
): ReducerHandlingContextMethods<State>
257+
): ReducerHandlingContext<State>
258258
/**
259259
* Provides access to the initial state value given to the slice.
260260
* If a lazy state initializer was provided, it will be called and a fresh value returned.
@@ -319,7 +319,7 @@ export type ReducerCreator<Type extends RegisteredReducerType> = {
319319
handle<State>(
320320
details: ReducerDetails,
321321
definition: ReducerDefinitionsForType<Type>,
322-
context: ReducerHandlingContextMethods<State>,
322+
context: ReducerHandlingContext<State>,
323323
): void
324324
})
325325

@@ -892,14 +892,14 @@ export function buildCreateSlice<
892892

893893
const getInitialState = makeGetInitialState(options.initialState)
894894

895-
const context: ReducerHandlingContext<State> = {
895+
const context: InternalReducerHandlingContext<State> = {
896896
sliceCaseReducersByName: {},
897897
sliceCaseReducersByType: {},
898898
actionCreators: {},
899899
sliceMatchers: [],
900900
}
901901

902-
const contextMethods: ReducerHandlingContextMethods<State> = {
902+
const contextMethods: ReducerHandlingContext<State> = {
903903
addCase(
904904
typeOrActionCreator: string | TypedActionCreator<any>,
905905
reducer: CaseReducer<State>,

packages/toolkit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export type {
8787
ReducerCreatorEntry,
8888
ReducerCreator,
8989
ReducerDetails,
90-
ReducerHandlingContextMethods,
90+
ReducerHandlingContext,
9191
SliceActionType,
9292
CaseReducerDefinition,
9393
PreparedCaseReducerDefinition,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
ReducerCreatorEntry,
1515
ReducerCreators,
1616
ReducerDefinition,
17-
ReducerHandlingContextMethods,
17+
ReducerHandlingContext,
1818
SliceActionType,
1919
SliceCaseReducers,
2020
ThunkAction,
@@ -814,7 +814,7 @@ describe('type tests', () => {
814814
}
815815
}
816816
Object.assign(openToast, { toastOpened, toastClosed })
817-
;(context as any as ReducerHandlingContextMethods<ToastState>)
817+
;(context as any as ReducerHandlingContext<ToastState>)
818818
.addCase(toastOpened, (state, { payload: { message, id } }) => {
819819
state.toasts[id] = { message }
820820
})

0 commit comments

Comments
 (0)