Skip to content

Commit 7a22377

Browse files
committed
fix typing for #ap method
1 parent 9c90589 commit 7a22377

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CHANGELOG
22
=========
33

44
## HEAD (Unreleased)
5-
_(none)_
5+
* Fix typing for `#ap`
66

77
---
88

src/lib/randomator.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ describe('Randomator', () => {
109109

110110
test('#ap', () => {
111111
const r$ = ab$.map(_ => _.toUpperCase());
112-
expect(r$.ap('c')).toMatch(/C/);
112+
const v = r$.ap('c');
113+
expect(v).toMatch(/C/);
113114
});
114115

115116
test('#ap throws on unmapped randomator', () => {

src/lib/randomator.test-d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ expectType<number>(j$());
4949
// toArray
5050
const k = e$.toArray(5);
5151
expectType<number[]>(k);
52+
53+
// switchMap
54+
const l$ = e$.map(n => n + n);
55+
const m$ = l$.switchMap(a$);
56+
expectType<string>(m$());
57+
58+
// ap
59+
const n = l$.ap(10);
60+
expectType<number>(n);

src/lib/randomator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class Randomator<T = unknown> extends Function implements Iterator<T> {
8888
* @param value A value
8989
* @returns
9090
*/
91-
ap<U>(value: unknown): U {
91+
ap(value: unknown): T {
9292
const mapping = this[MappingFunction];
9393
if (!mapping) {
9494
throw new Error('ap can only be called on a mapped Randomator');

0 commit comments

Comments
 (0)