I have a function, which I want to ensure takes a string, followed by a number. And optionally, more string number pairs. So like a tuple, but "infinite" times:
const fn = (...args: [string, number] |
[string, number, string, number] |
[string, number, string, number, string, number] |
[string, number, string, number, string, number, string, number] | ...etc etc) => {}
and so on
An alternative psuedo type construction:
type Pair = [string, number, ...Pair];
Is this possible with TypeScript?
EDIT This looks like it should work, but doesn't. TypeScript does not seem to infer the order of the pairs correctly.
type Pair = [string, number, ...Pair[]];