// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead type TypeList = string | number | boolean | undefined | null | void | Record /** * @deprecated use `as const` instead * * e.g * ```ts * const BASE_COLORS = tuple('red', 'green', 'blue') * type BaseColor = (typeof BASE_COLORS)[number] * ``` * * aka * ```ts * // **NOTE** Do not miss `as const` assertion * const BASE_COLORS = ['red', 'green', 'blue'] as const * type BaseColor = (typeof BASE_COLORS)[number] * ``` */ export function tuple(...args: T) { return args } export interface Dictionary { [key: string]: T } export type StringIndexedObject = Dictionary export type JsonPrimitive = string | number | boolean | null export type Json = JsonPrimitive | JsonObject | JsonArray export type JsonArray = Json[] export interface JsonObject { [member: string]: Json } // export interface JsonArray extends Array {} export type JsonCompatible = { [P in keyof T]: T[P] extends Json ? T[P] : Pick extends Required> ? never : JsonCompatible; } export type AnyFunction = (...args: any[]) => RT export type BivarianceHackCallback = { bivarianceHack(...ars: T): Val }['bivarianceHack']