#Spreading iterator as function arguments
7 messages · Page 1 of 1 (latest)
7 messages · Page 1 of 1 (latest)
A weird pattern, but is this possible to make TS aware that spreading Foo will effectively result in [number, number] and thus allowed to be passed as arguments to func?
class Foo {
*[Symbol.iterator]() {
yield 1
yield 2
}
}
declare function func(num1: number, num2: number): void
func(...new Foo())
nope
Foo is an Iterable<1 | 2>
i don't think there's a way to specify a tuple instead of the item type
(@novel shoal -^)