// ets_tracing: off import type { UnionToIntersection } from "../../Utils/index.js" import type { Param } from "./fix.js" import type { OrNever } from "./or-never.js" export type Variance = "+" | "-" | "_" export interface V { Variance: { [v in V]: () => F } } // composes types according to variance specified in C export type Mix = C extends V ? X[0] : C extends V ? X[number] : C extends V ? X extends [any] ? X[0] : X extends [any, any] ? X[0] & X[1] : X extends [any, any, any] ? X[0] & X[1] & X[2] : X extends [any, any, any, any] ? X[0] & X[1] & X[2] & X[3] : X extends [any, any, any, any, any] ? X[0] & X[1] & X[2] & X[3] & X[4] : X extends [any, any, any, any, any, any] ? X[0] & X[1] & X[2] & X[3] & X[4] & X[5] : UnionToIntersection<{ [k in keyof X]: OrNever }[keyof X]> : X[0] // composes a record of types to the base respecting variance from C export type MixStruct = C extends V ? X : C extends V ? Y[keyof Y] : C extends V ? UnionToIntersection<{ [k in keyof Y]: OrNever }[keyof Y]> : X // used in subsequent definitions to either vary a paramter or keep it fixed to "Fixed" export type Intro = C extends V ? Fixed : C extends V ? Current : C extends V ? Current : Fixed // initial type depending on variance of P in C (eg: initial Contravariant R = unknown, initial Covariant E = never) export type Initial = C extends V ? unknown : C extends V ? never : any