Skip to content

Commit f48d26e

Browse files
Clarify types in TimelineIterator
1 parent d8e9166 commit f48d26e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/library/src/base/util/iterators/timeline.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export class SliceIterable<T> {
1818
#extractIterator: (
1919
v: NestedIterable<T>,
2020
) => Promise<Iterator<T | NestedIterable<T>>>
21-
#checkIterator: (v: NestedIterable<T>) => boolean
21+
#checkIterator: (v: NestedIterable<T> | T) => boolean
2222

2323
// TODO: Helper functions are necessary because components
2424
// do not follow the iterator protocol; when this change
2525
// is implemented, the helpers can be removed.
2626
constructor(
2727
root: NestedIterable<T>,
2828
extractIterator = async (v: NestedIterable<T>) => v[Symbol.iterator](),
29-
checkIterator = (v: NestedIterable<T>) => Symbol.iterator in v,
29+
checkIterator = (v: NestedIterable<T> | T) => Symbol.iterator in v,
3030
) {
3131
this.#root = root
3232
this.#extractIterator = extractIterator
@@ -82,7 +82,9 @@ export class SliceIterable<T> {
8282
} else {
8383
if (this.#checkIterator(value)) {
8484
outputStack.push(value)
85-
iteratorStack.push(await this.#extractIterator(value))
85+
// We know that the value is an iterator
86+
// courtesy of the condition above
87+
iteratorStack.push(await this.#extractIterator(value as NestedIterable<T>))
8688
} else {
8789
return { value: [...outputStack, value], done: false }
8890
}

0 commit comments

Comments
 (0)