I have function which returns union type of tuples. I want to pass it to function which accepts all its forms using spread operator ....
type TupleUnion = readonly [number, number] | readonly [number, number, string]
function getTuple() : TupleUnion
function calc(a, b, c?)
const tuple = getTuple();
calc(...tuple)
However on last line typescript compiler complains:
A spread argument must either have a tuple type or be passed to a rest parameter.ts(2556)
I do not want to redefine calc function. I need function getTuple to return union type which supports spread operator.