// This Tuple type (and tuple() function) is a hack to induce // TypeScript to infer tuple types rather than array types. (Source: // https://github.com/microsoft/TypeScript/issues/27179#issuecomment-422606990) // // Without it, [123, 'hi', true] will often get the type (string | // number | boolean)[] instead of [number, string, boolean]. export type Tuple = T[] | [T]; export const tuple = >(... args: A) => args; export const Tuple = Array; export type TupleMap, V> = Tuple & { [K in keyof T]: V; }