import { IsAny, IsAnyOrUnknown, IsUnknown, Iteration, KeyValuate } from "@re-do/utils" import { ParseConfig, ShallowCycleError } from "./internal.js" import { Root } from "../root.js" import { References } from "../../references.js" type CheckReferencesForShallowCycle< References extends string[], TypeSet, Seen > = References extends Iteration ? CheckForShallowCycleRecurse< KeyValuate, TypeSet, Seen | Current > extends never ? CheckReferencesForShallowCycle : CheckForShallowCycleRecurse< KeyValuate, TypeSet, Seen | Current > : never type CheckForShallowCycleRecurse = IsAny extends true ? never : Def extends Seen ? Seen : Def extends string ? CheckReferencesForShallowCycle< References, TypeSet, Seen > : never type CheckForShallowCycle = CheckForShallowCycleRecurse< Def, TypeSet, never > export namespace TypeSetMember { export type Definition = Def export type Validate = IsAny extends true ? "any" : CheckForShallowCycle extends never ? Root.Validate : ShallowCycleError> export type Parse = Root.Parse< Def, TypeSet, Options > }