Skip to content

Commit 33c5d66

Browse files
committed
Add type check for AsyncIterator
1 parent c10c783 commit 33c5d66

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/type-definitions/helpers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,17 @@ export interface CoreJSIteratorLike<T, TReturn = any, TNext = any> extends Itera
5050
join(...args: any[]): string;
5151
}
5252
export type CoreJSIteratorAndIteratorLike<T> = CoreJSIteratorLike<T> & Iterator<T>;
53+
54+
export interface CoreJSAsyncIteratorLike<T, TReturn = any, TNext = any> {
55+
drop(...args: any[]): any;
56+
every(...args: any[]): any;
57+
filter(...args: any[]): any;
58+
find(...args: any[]): any;
59+
flatMap(...args: any[]): any;
60+
forEach(...args: any[]): any;
61+
map(...args: any[]): any;
62+
reduce(...args: any[]): any;
63+
some(...args: any[]): any;
64+
take(...args: any[]): any;
65+
toArray(...args: any[]): any;
66+
}

tests/type-definitions/pure/proposals/async-iterator-helper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import some from '@core-js/pure/full/async-iterator/some';
1111
import take from '@core-js/pure/full/async-iterator/take';
1212
import toArray from '@core-js/pure/full/async-iterator/to-array';
1313
import toAsync from '@core-js/pure/full/iterator/to-async';
14-
// import $AsyncIterator from '@core-js/pure/full/async-iterator'; // todo
15-
import { CoreJSPromiseAndPromiseLike } from '../../helpers';
14+
import { CoreJSAsyncIteratorLike, CoreJSPromiseAndPromiseLike } from '../../helpers';
1615

16+
const aitn: CoreJSAsyncIteratorLike<number> = from([1]);
1717
const aiton = from([1, 2, 3]);
1818
aiton.next();
1919
aiton.toArray();

0 commit comments

Comments
 (0)