Imagine having a tuple in TypeScript like this:
type MyTuple = [string, number];
Now, the goal is to find the union of all numeric keys for this tuple, such as 0 | 1
. This can be achieved using the following code snippet:
type MyKeys = Exclude<keyof MyTuple, keyof unknown[]>;
This will result in the type "0" | "1"
, which represents a union of string literals. However, is there a way to obtain a union of number literals instead?