swc/crates/swc_bundler/tests/.cache/untrusted/f1dae189eb48ebd5cbc7be7a51ed4f2fdbcecd44.ts
2021-11-09 20:42:49 +09:00

48 lines
1.3 KiB
TypeScript

// Loaded from https://raw.githubusercontent.com/colinhacks/zod/654680afc2ede388e71e09104eac5a0088fe3207/deno/lib/types/intersection.ts
import { ZodTypes } from "../ZodTypes.ts";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base.ts";
// import { ZodUndefined } from './undefined';
// import { ZodNull } from './null';
// import { ZodUnion } from './union';
export interface ZodIntersectionDef<
T extends ZodTypeAny = ZodTypeAny,
U extends ZodTypeAny = ZodTypeAny
> extends ZodTypeDef {
t: ZodTypes.intersection;
left: T;
right: U;
}
export class ZodIntersection<
T extends ZodTypeAny,
U extends ZodTypeAny
> extends ZodType<
T["_output"] & U["_output"],
ZodIntersectionDef<T, U>,
T["_input"] & U["_input"]
> {
// opt optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]);
// null nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]);
toJSON = () => ({
t: this._def.t,
left: this._def.left.toJSON(),
right: this._def.right.toJSON(),
});
static create = <T extends ZodTypeAny, U extends ZodTypeAny>(
left: T,
right: U
): ZodIntersection<T, U> => {
return new ZodIntersection({
t: ZodTypes.intersection,
left: left,
right: right,
});
};
}