-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: proper typing on foreach return inside the pipe
- Loading branch information
1 parent
1e90713
commit 799a66c
Showing
3 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { Kind } from '../common'; | ||
|
||
export type ForEachFn<T> = (value: T, index: number) => void; | ||
export type ForEach<T> = { | ||
kind: Kind.FOR_EACH; | ||
run: ForEachFn<T>; | ||
run: (value: T, index: number) => T; | ||
}; | ||
|
||
/** | ||
* rxjs "tap" analogue | ||
* does not change array values | ||
*/ | ||
export function forEach<TValue>(fn: ForEachFn<TValue>): ForEach<TValue> { | ||
export function forEach<T>(fn: (value: T, index: number) => void): ForEach<T> { | ||
return { | ||
kind: Kind.FOR_EACH, | ||
run: fn | ||
run: fn as (value: T, index: number) => T, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters