Given
TUPLE: Any tuple
Provide
A type that defines an object type whose keys and the corresponding value types would be the tuple indices and the corresponding tuple element types.
type TupleToObject<TUPLE> = { [I in keyof TUPLE & `${number}`]: TUPLE[I] }
Reference
https://stackoverflow.com/a/75746375/22340824
https://stackoverflow.com/a/70398429/22340824
Get union of bool elements indices.
const arr = [true, false, 'test'] as const;
type BoolIndices = StringToNumber<ConditionalKeys<TupleToObject<typeof arr>, boolean>>;
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