mirror of
https://github.com/stablyai/orca.git
synced 2026-09-24 00:02:24 +00:00
test(relay): type countingIterator as MapIterator and drop two suppressions
The wrapper only ever receives a Map iterator, so declaring that removes the cast at both call sites; one irreducible cast stays on the object literal, which cannot satisfy MapIterator's full surface. Three suppressions become one.
This commit is contained in:
@@ -12,7 +12,7 @@ class CountingMap<K, V> extends Map<K, V> {
|
||||
visits = 0
|
||||
getCalls = 0
|
||||
|
||||
private countingIterator<T>(inner: IterableIterator<T>): IterableIterator<T> {
|
||||
private countingIterator<T>(inner: MapIterator<T>): MapIterator<T> {
|
||||
const bump = (): void => {
|
||||
this.visits++
|
||||
}
|
||||
@@ -28,17 +28,15 @@ class CountingMap<K, V> extends Map<K, V> {
|
||||
[Symbol.iterator]() {
|
||||
return this
|
||||
}
|
||||
} as IterableIterator<T>
|
||||
} as MapIterator<T>
|
||||
}
|
||||
|
||||
override [Symbol.iterator](): MapIterator<[K, V]> {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: countingIterator wraps the real Map iterator and forwards every next() to it, so the result is that iterator with a counter attached.
|
||||
return this.countingIterator(super[Symbol.iterator]()) as MapIterator<[K, V]>
|
||||
return this.countingIterator(super[Symbol.iterator]())
|
||||
}
|
||||
|
||||
override values(): MapIterator<V> {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the same wrapper as [Symbol.iterator] above, over super.values().
|
||||
return this.countingIterator(super.values()) as MapIterator<V>
|
||||
return this.countingIterator(super.values())
|
||||
}
|
||||
|
||||
override get(key: K): V | undefined {
|
||||
|
||||
Reference in New Issue
Block a user