Skip to content

Commit f9a2966

Browse files
committed
Fix Iterator / Iterable confusion.
Turns out that Map values() and entries() return an object which is both an Iterator *and* an iterable!
1 parent ddd385e commit f9a2966

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/test/unit/path.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,9 @@ describe('PathSet', function () {
107107
it('implements iterable, .values, .entries', function () {
108108
const set = new PathSet(sampleValues);
109109
expect(Array.from(set)).toEqual(sampleValues);
110-
// @ts-expect-error The TypeScript definition of Array.from only accepts Iterable, not Iterator - not sure what's correct here
111-
expect(Array.from<CallNodePath>(set.values())).toEqual(sampleValues);
110+
expect(Array.from(set.values())).toEqual(sampleValues);
112111

113112
const expectedEntries = sampleValues.map((val) => [val, val]);
114-
// @ts-expect-error The TypeScript definition of Array.from only accepts Iterable, not Iterator - not sure what's correct here
115113
expect(Array.from(set.entries())).toEqual(expectedEntries);
116114
});
117115
});

src/utils/path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export class PathSet implements Iterable<CallNodePath> {
8383
return this._table.delete(hashPath(path));
8484
}
8585

86-
*values(): Iterator<CallNodePath> {
86+
*values(): IterableIterator<CallNodePath> {
8787
yield* this._table.values();
8888
}
8989

90-
*entries(): Iterator<[CallNodePath, CallNodePath]> {
90+
*entries(): IterableIterator<[CallNodePath, CallNodePath]> {
9191
for (const entry of this) {
9292
yield [entry, entry];
9393
}

0 commit comments

Comments
 (0)