Can be useful sometimes to find the index of a type in a readonly array (tuple), IE:
type Tuple = [T1, T2, T3];
type Index = IndexOf<Tuple, T1> // '0';
This works:
export type Indexes<V extends readonly any[]> = {
[K in Exclude<keyof V, keyof Array<any>>]: K;
};
export type IndexOf<V extends readonly any[], T> = {
[I in keyof Indexes<V>]: V[I] extends T
? T extends V[I]
? I
: never
: never;
}[keyof Indexes<V>];
It's possible to do some cool stuff with this
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too