import { t as Join } from "./strings-DWgkUybS.js"; //#region src/utils/types.d.ts type IsAny = 0 extends (1 & T) ? true : false; type IsNever = [T] extends [never] ? true : false; type IsNullish = [T] extends [null | undefined] ? true : false; type IsUnion = IsNever extends true ? false : IsAny extends true ? false : T extends U ? ([U] extends [T] ? false : true) : never; type NullishCoalesce = T extends null | undefined ? U : T; type LastUnionElement = UnionToIntersection 0 : never> extends ((x: infer L) => 0) ? L & U : never; type primitive = string | number | boolean | bigint | symbol | null | undefined; /** * Makes a type prettier by recursively expanding all object types. For example, `Omit<{ a: 1 }, "a">` becomes just `{}`. */ type Expand = T extends ((...args: infer A) => infer R) ? ((...args: A) => R) extends T ? (...args: Expand) => Expand : ((...args: Expand) => Expand) & { [K in keyof T]: Expand } : T extends object ? T extends primitive ? T : T extends infer O ? { [K in keyof O]: Expand } : never : T; /** * Removes all optional undefined/never keys from an object. */ type DeepRemoveOptionalUndefined = T extends object ? { [K in keyof T]: DeepRemoveOptionalUndefined } : T; type UnionToIntersection = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never; type _UnionToTupleInner = UnionToTuple, [...R, Last]>; type UnionToTuple = [U] extends [never] ? R : _UnionToTupleInner>; type CollapseObjectUnion = { [K in AllUnionKeys]?: T extends Record ? V : never }; type IntersectAll = UnionToIntersection; type OptionalKeys = { [K in keyof T]: {} extends Pick ? K : never }[keyof T]; type RequiredKeys = { [K in keyof T]: {} extends Pick ? never : K }[keyof T]; /** * Returns a type whose keys are the intersection of the keys of T and U, deeply. */ type KeyIntersect = { [K in keyof T & keyof U]?: T[K] & U[K] } & { [K in RequiredKeys & keyof U]: T[K] & U[K] } & { [K in RequiredKeys & keyof T]: U[K] & T[K] }; /** * Returns ALL keys of all union elements. */ type AllUnionKeys = T extends T ? keyof T : never; type SubtractType = T extends object ? { [K in keyof T]: K extends keyof U ? SubtractType : T[K] } : (T extends U ? never : T); type XOR = T extends readonly [infer A, infer B, ...infer Rest] ? Rest extends [] ? (A & { [K in keyof B]?: never }) | (B & { [K in keyof A]?: never }) : XOR<[(A & { [K in keyof B]?: never }) | (B & { [K in keyof A]?: never }), ...Rest]> : T[0]; type _AntiIntersectInner = T extends object ? (Omit & { [K in keyof Pick]: PseudoAntiIntersect } & { [K in keyof Pick]?: PseudoAntiIntersect }) : U; /** * Returns a type R such that T & R = U. */ type AntiIntersect = U extends T ? _AntiIntersectInner : "Cannot anti-intersect a type with a type that is not a subtype of it"; type PseudoAntiIntersect = _AntiIntersectInner; /** * A variation of TypeScript's conditionals with slightly different semantics. It is the perfect type for cases where: * * - If all possible values are contained in `Extends`, then it will be mapped to `Then`. * - If all possible values are not contained in `Extends`, then it will be mapped to `Otherwise`. * - If some possible values are contained in `Extends` and some are not, then it will be mapped to `Then | Otherwise`. * * This is different from TypeScript's built-in conditional types (`Value extends Extends ? Then : Otherwise`), which * returns `Otherwise` for the third case (causing unsoundness in many real-world cases). */ type IfAndOnlyIf = (Value extends Extends ? never : Otherwise) | (Value & Extends extends never ? never : Then); /** * Can be used to prettify a type in the IDE; for example, some complicated intersected types can be flattened into a single type. */ type PrettifyType = T extends object ? { [K in keyof T]: T[K] } & {} : T; type _ToStringAndJoin = T extends [infer U, ...infer Rest extends any[]] ? `${TypeToString}${Rest extends [any, ...any[]] ? `${Separator}${_ToStringAndJoin}` : ""}` : ""; type _TypeToStringInner = IsAny extends true ? "any" : IsNever extends true ? "never" : IsUnion extends true ? _ToStringAndJoin, " | "> : [T] extends [number] ? (number extends T ? "number" : `${T}`) : [T] extends [boolean] ? `${T}` : [T] extends [undefined] ? "undefined" : [T] extends [null] ? "null" : [T] extends [string] ? (string extends T ? "string" : `'${T}'`) : [T] extends [[]] ? "[]" : [T] extends [[any, ...any[]]] ? `[${_ToStringAndJoin}]` : [T] extends [(infer E)[]] ? `${TypeToString}[]` : [T] extends [Function] ? "function" : [T] extends [symbol] ? `symbol(${T['description']})` : [T] extends [object] ? `{ ${Join}: ${TypeToString}` }[keyof T]>, ", ">} }` : ""; type TypeToString = _TypeToStringInner extends `${infer S}` ? S : never; /** * Can be used to create assertions on types. For example, if passed any T other than `true`, the following will * show a type error: * * ```ts * typeAssert()(); // the second pair of braces is important! * ``` */ declare function typeAssert(): (IsAny extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got any.`> : IsNever extends true ? TypeAssertionError<`Type assertion failed. Expected true, but got never.`> : T extends true ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected true, but got: ${TypeToString}`>); type TypeAssertionError = [T] & /* this promise makes sure that if we accidentally forget the second pair of braces, eslint will complain (if we have no-floating-promises enabled) */Promise; /** * Functionally equivalent to `typeAssert()()`, but with better error messages. */ declare function typeAssertExtends(): ([T] extends [S] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString} to extend ${TypeToString}`>); declare function typeAssertIs(): (IsAny extends true ? (IsAny extends true ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString} to be ${TypeToString}`>) : IsAny extends true ? TypeAssertionError<`Type assertion failed. Expected ${TypeToString} to be ${TypeToString}`> : [T] extends [U] ? ([U] extends [T] ? (() => undefined) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString} to be ${TypeToString}`>) : TypeAssertionError<`Type assertion failed. Expected ${TypeToString} to be ${TypeToString}`>); //#endregion export { XOR as C, typeAssertIs as E, UnionToTuple as S, typeAssertExtends as T, PseudoAntiIntersect as _, Expand as a, TypeToString as b, IsAny as c, IsUnion as d, KeyIntersect as f, PrettifyType as g, OptionalKeys as h, DeepRemoveOptionalUndefined as i, IsNever as l, NullishCoalesce as m, AntiIntersect as n, IfAndOnlyIf as o, LastUnionElement as p, CollapseObjectUnion as r, IntersectAll as s, AllUnionKeys as t, IsNullish as u, RequiredKeys as v, typeAssert as w, UnionToIntersection as x, SubtractType as y }; //# sourceMappingURL=types-DfTcxNtM.d.ts.map