Skip to content

Commit 7cac225

Browse files
committed
fix(type): use PatchesOptions type
1 parent bf2bf5a commit 7cac225

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/index.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,18 @@ import {
44
type Patches,
55
type Options,
66
type Draft,
7+
type PatchesOptions,
78
} from 'mutative';
89
import {
910
useState,
1011
useReducer,
1112
useCallback,
1213
useMemo,
1314
useRef,
14-
Dispatch,
15+
type Dispatch,
1516
useEffect,
1617
} from 'react';
1718

18-
type PatchesOptions =
19-
| boolean
20-
| {
21-
/**
22-
* The default value is `true`. If it's `true`, the path will be an array, otherwise it is a string.
23-
*/
24-
pathAsArray?: boolean;
25-
/**
26-
* The default value is `true`. If it's `true`, the array length will be included in the patches, otherwise no include array length.
27-
*/
28-
arrayLengthAssignment?: boolean;
29-
};
30-
3119
type DraftFunction<S> = (draft: Draft<S>) => void;
3220
type Updater<S> = (value: S | (() => S) | DraftFunction<S>) => void;
3321

@@ -302,12 +290,12 @@ function useMutativeReducer<
302290
}
303291
});
304292
return options?.enablePatches
305-
? [
293+
? ([
306294
result[0],
307295
result[1],
308296
patchesRef.current.patches,
309297
patchesRef.current.inversePatches,
310-
] as ReducerResult<S, A, O, F>
298+
] as ReducerResult<S, A, O, F>)
311299
: result;
312300
}
313301

0 commit comments

Comments
 (0)