Skip to content

Commit 5fc54cb

Browse files
chore(stackflow/core): Type inference friendly divideBy (#557)
1 parent 18609d1 commit 5fc54cb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.changeset/four-colts-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackflow/core": patch
3+
---
4+
5+
Made `divideBy` to be friendly to type inference.

core/src/makeCoreStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function makeCoreStore(options: MakeCoreStoreOptions): CoreStore {
6161
initialEvents,
6262
initialContext: options.initialContext ?? {},
6363
}) ?? initialEvents,
64-
initialPushedEventsByOption as (PushedEvent | StepPushedEvent)[],
64+
initialPushedEventsByOption,
6565
);
6666

6767
const isInitialActivityIgnored =

core/src/utils/divideBy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export const divideBy = <T>(
1+
export const divideBy = <T, U extends T>(
22
arr: T[],
3-
predicate: (t: T) => boolean,
4-
): [T[], T[]] => {
5-
const satisfied: T[] = [];
3+
predicate: (t: T) => t is U,
4+
): [U[], T[]] => {
5+
const satisfied: U[] = [];
66
const unsatisfied: T[] = [];
77

88
arr.forEach((element) => {

0 commit comments

Comments
 (0)