I have a method that should accept either an array of numbers or accept a variable number of number arguments (variadic). In most languages I've used, when you make a method/function variadic, it accepts both, but it seems that in TypeScript, you cannot. When I make this particular function variadic, all of the places where I supply a number[]
fail compilation.
Signature for reference (in class ObjectIdentifier
):
constructor(... nodes : number[]) {
This fails:
return new ObjectIdentifier(numbers);
where numbers
is of type number[]
.