import { EdgeMultiplicity } from "./edges.js"; //#region src/core/interfaces/vertices/util/util.d.ts /** * Similar to O[K], but does not require K to be a key of O. Extracts the property K from each member of the possible union types in U. */ type GetByKey = O extends { [P in K]: infer T } ? T : O extends { [P in K]?: infer T } ? T | undefined : never; /** * keyof { a1: ..., a2: ..., ... } | { b1: ..., b2: ..., ... } | ... => 'a1' | 'a2' | ... | 'b1' | 'b2' | ... */ type AllKeys = U extends any ? keyof U : never; declare namespace MakeMixedNs { type ExtractArrayType = T extends Array ? T : never; type ExtractObjectType = T extends Array ? never : T extends object ? T : never; type _MakeMixedArray = [T] extends [never] ? never : (T extends Array ? U : never) extends infer U ? Array> : never; type _MakeMixedObject = [T] extends [never] ? never : { [K in AllKeys]: MakeMixed> }; export type MakeMixed = (ExtractArrayType extends (infer V extends any[]) ? _MakeMixedArray : never) | (ExtractObjectType extends (infer V extends object) ? _MakeMixedObject : never) | (T extends object ? never : T); export {}; } /** * Merges a union of types into a single type by combining properties of object types and merging array element types. */ type MakeMixed = MakeMixedNs.MakeMixed; /** * Deep partial type that allows for partial properties at any level of nesting. */ type DeepPartial = T extends Array ? Array> : T extends object ? { [K in keyof T]?: DeepPartial } : T; /** * A deep version of NonNullable that recursively removes null and undefined from all properties and nested properties. */ type DeepNonNullable = T extends any ? T extends ((...args: any[]) => any) ? T : T extends Array ? Array>> : T extends object ? { [K in keyof T]-?: DeepNonNullable> } : NonNullable : never; type _IsUnion = T extends any ? [U] extends [T] ? false : true : never; /** * Lets a type pass if it is a union type, otherwise returns `never`. */ type IsUnion = _IsUnion extends true ? T : never; /** * Returns never if any type in the tuple is a union, otherwise returns the tuple. */ type NoneIsUnion = AnyUnion extends true ? never : T; type AnyUnion = T extends [infer Head, ...infer Tail] ? _IsUnion extends true ? true : AnyUnion : false; /** * Returns `true` if every element in the tuple is `true`, otherwise returns `false`. * Returns `never` for an empty tuple. */ type AllTrue = T extends [] ? never : _AllTrue; type _AllTrue = T extends [infer Head, ...infer Tail] ? Head extends true ? Tail extends any[] ? _AllTrue : never : false : true; /** * Returns the tail of a tuple, or `never` if the tuple is empty. */ type Tail = T extends [any, ...infer V extends [any, ...any[]]] ? Tail : T extends [infer U] ? U : never; /** * Prettify * Materializes T into a plain object type for clearer tooltips and stable structural equality. * * Preserves: * - Keys, property types, and readonly/optional modifiers (homomorphic mapping). * * Useful for: * - Flattening intersections and mapped types into a single object-like shape so * libraries like ts-expect's TypeEqual consider two equivalent types equal. * * Notes: * - Does not change semantics or add/remove properties. * - Inner unions remain unions; only the outer shape is normalized. * - The `& {}` forces recomputation and a simpler displayed shape in editor/tooling. */ type Prettify = { [K in keyof T]: T[K] } & {}; /** * Wraps the given type T into an array if its multiplicity M is 'array'. */ type SetMultiplicity = M extends 'array' ? T[] : T; /** * Extracts null and undefined from a type T, resulting in `null | undefined` if both are present, otherwise `null`, `undefined`, or `never`. */ type ExtractNullish = Extract; //#endregion export { AllKeys, AllTrue, DeepNonNullable, DeepPartial, ExtractNullish, IsUnion, MakeMixed, NoneIsUnion, Prettify, SetMultiplicity, Tail }; //# sourceMappingURL=util.d.ts.map