#What's up with this "is referenced directly or indirectly in its own initializer" type error?

6 messages ยท Page 1 of 1 (latest)

keen owlBOT
#
tomeraberbach#0

Preview:```ts
export type Range = [number, number]
export type RangeEntry<Value> = [Range, Value]

const fails = (
map: Map<number, unknown>
): RangeEntry<unknown>[] => {
const entries: RangeEntry<unknown>[] = []

let currentEntry: RangeEntry<unknown> | undefined =
undefined
for (const [key, value]
...```

finite snow
#

I don't understand why the fails function has a type error, but the passes one doesn't? Am I missing something super obvious?

#

I've been staring at this for a while, but the code seems okay to me...?

#

If I comment out currentEntry = [[key, key], value] at the end of the loop it stops complaining ๐Ÿ˜…

#

What in the world is going on