You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/api/createSlice.mdx
+92-94
Original file line number
Diff line number
Diff line change
@@ -809,7 +809,7 @@ context
809
809
810
810
The Typescript system for custom slice creators uses a "creator registry" system similar to the module system for [RTK Query](/rtk-query/usage/customizing-create-api#creating-your-own-module).
811
811
812
-
Creators are registered by using module augmentation to add a new key (their unique `type`) to the `SliceReducerCreators` interface. The interface receives three type parameters (`State`, `CaseReducers` and `Name`), and each entry should have three keys (`create`, `actions`, and `caseReducers`).
812
+
Creators are registered by using module augmentation to add a new key (their unique `type`) to the `SliceReducerCreators` interface. The interface receives three type parameters (`State`, `CaseReducers` and `Name`), and each entry should have use the `ReducerCreatorEntry` type utility.
All three keys must be provided, even if the creator only returns definitions for other creators. If the creator doesn't expose any actions/case reducers itself, leave those keys as `{}`.
830
+
The `ReducerCreatorEntry<Create, Exposes>` utility has two type parameters:
835
831
836
-
:::
837
-
838
-
#### `create`
832
+
#### `Create`
839
833
840
834
The signature of the `create` method of the creator definition.
@@ -881,7 +873,13 @@ The second argument to the `ReducerCreators` type is a map from creator names to
881
873
882
874
:::
883
875
884
-
#### `actions`
876
+
#### `Exposes`
877
+
878
+
The second type parameter for `ReducerCreatorEntry` is optional, but should be used if the creator will handle some reducer definitions itself. It indicates what actions and case reducers will be attached to the slice, and is used to determine the final types of `slice.actions` and `slice.caseReducers`.
879
+
880
+
It should be an object with some of the following properties:
881
+
882
+
##### `actions`
885
883
886
884
The actions property will typically be a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html) over the `CaseReducers` type parameter, returning what the creator's `handle` would expose when given that definition.
The `actions` returned from all the creators when passed the `CaseReducers` definitions are all intersected to create the final type for `slice.actions`.
926
-
927
-
#### `caseReducers`
924
+
##### `caseReducers`
928
925
929
926
Similar to `actions`, except for `slice.caseReducers`.
0 commit comments