Files
SnowLuma/.pnpm-store/v11/files/23/cb1f866cb17a1d57d7e61f85bb165863593c0e0dfe1a49d75f9eeb1878fbca1a6eb85b4ccb743e98577eed825d8a899be60a3c4ff08cd6219069bf69056972
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

31 lines
1.1 KiB
Plaintext

import * as schemas from "./schemas.js";
type AnyZod = schemas.$ZodType;
type Kind = schemas.$ZodTypeDef["type"];
/** The concrete schema class for a `def.type`, or `$ZodType` for kinds with no dedicated class. */
type SchemaOfKind<K extends Kind> = [Extract<schemas.$ZodTypes, {
_zod: {
def: {
type: K;
};
};
}>] extends [never] ? AnyZod : Extract<schemas.$ZodTypes, {
_zod: {
def: {
type: K;
};
};
}>;
export type VisitFn = (node: AnyZod, rewritten: boolean) => AnyZod;
export type VisitHandlers = {
[K in Kind]?: (node: SchemaOfKind<K>, rewritten: boolean) => AnyZod;
};
/**
* @internal Bottom-up rewrite of a schema tree. Unhandled kinds and unchanged branches keep their
* identity. Returns `$ZodType`: a visitor can swap in a schema of any type, so callers declare
* their own return type. `rewritten` tells a handler whether the traversal replaced anything
* below the node it is looking at.
*/
export declare function visit(schema: schemas.SomeType, fn: VisitFn): AnyZod;
export declare function visit(schema: schemas.SomeType, handlers: VisitHandlers): AnyZod;
export {};