Skip to content

Commit ff73b33

Browse files
author
Thibault Gouala
committed
move new generic to the end and default it to string
1 parent 74c8743 commit ff73b33

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

etc/redux-toolkit.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ export { createSelector }
112112
export function createSerializableStateInvariantMiddleware(options?: SerializableStateInvariantMiddlewareOptions): Middleware;
113113

114114
// @public
115-
export function createSlice<Name extends string, State, CaseReducers extends SliceCaseReducers<State>>(options: CreateSliceOptions<Name, State, CaseReducers>): Slice<Name, State, CaseReducers>;
115+
export function createSlice<State, CaseReducers extends SliceCaseReducers<State>, Name extends string = string>(options: CreateSliceOptions<State, CaseReducers, Name>): Slice<State, CaseReducers, Name>;
116116

117117
// @public
118-
export interface CreateSliceOptions<Name extends string, State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>> {
118+
export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string> {
119119
extraReducers?: CaseReducers<NoInfer<State>, any> | ((builder: ActionReducerMapBuilder<NoInfer<State>>) => void);
120120
initialState: State;
121121
name: Name;
@@ -182,7 +182,7 @@ export interface SerializableStateInvariantMiddlewareOptions {
182182
}
183183

184184
// @public
185-
export interface Slice<Name extends string, State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>> {
185+
export interface Slice<State = any, CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>, Name extends string = string> {
186186
actions: CaseReducerActions<CaseReducers>;
187187
caseReducers: SliceDefinedCaseReducers<CaseReducers>;
188188
name: Name;

src/createSlice.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export type SliceActionCreator<P> = PayloadActionCreator<P>
2828
* @public
2929
*/
3030
export interface Slice<
31-
Name extends string,
3231
State = any,
33-
CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>
32+
CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>,
33+
Name extends string = string
3434
> {
3535
/**
3636
* The slice name.
@@ -61,9 +61,9 @@ export interface Slice<
6161
* @public
6262
*/
6363
export interface CreateSliceOptions<
64-
Name extends string,
6564
State = any,
66-
CR extends SliceCaseReducers<State> = SliceCaseReducers<State>
65+
CR extends SliceCaseReducers<State> = SliceCaseReducers<State>,
66+
Name extends string = string
6767
> {
6868
/**
6969
* The slice's name. Used to namespace the generated action types.
@@ -213,12 +213,12 @@ function getType(slice: string, actionKey: string): string {
213213
* @public
214214
*/
215215
export function createSlice<
216-
Name extends string,
217216
State,
218-
CaseReducers extends SliceCaseReducers<State>
217+
CaseReducers extends SliceCaseReducers<State>,
218+
Name extends string = string
219219
>(
220-
options: CreateSliceOptions<Name, State, CaseReducers>
221-
): Slice<Name, State, CaseReducers> {
220+
options: CreateSliceOptions<State, CaseReducers, Name>
221+
): Slice<State, CaseReducers, Name> {
222222
const { name, initialState } = options
223223
if (!name) {
224224
throw new Error('`name` is a required option for createSlice')

0 commit comments

Comments
 (0)