swc/bundler/tests/.cache/untrusted/ad8f6cbfae0b5f967576c061d303529a48f8f004.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

46 lines
1.1 KiB
TypeScript

// Loaded from https://raw.githubusercontent.com/colinhacks/zod/654680afc2ede388e71e09104eac5a0088fe3207/deno/lib/types/map.ts
import { ZodTypes } from "../ZodTypes.ts";
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base.ts";
export interface ZodMapDef<
Key extends ZodTypeAny = ZodTypeAny,
Value extends ZodTypeAny = ZodTypeAny
> extends ZodTypeDef {
t: ZodTypes.map;
valueType: Value;
keyType: Key;
}
export class ZodMap<
Key extends ZodTypeAny = ZodTypeAny,
Value extends ZodTypeAny = ZodTypeAny
> extends ZodType<
Map<Key["_output"], Value["_output"]>,
ZodMapDef<Key, Value>,
Map<Key["_input"], Value["_input"]>
> {
readonly _value!: Value;
toJSON = () => ({
t: this._def.t,
valueType: this._def.valueType.toJSON(),
keyType: this._def.keyType.toJSON(),
});
static create = <
Key extends ZodTypeAny = ZodTypeAny,
Value extends ZodTypeAny = ZodTypeAny
>(
keyType: Key,
valueType: Value
): ZodMap<Key, Value> => {
return new ZodMap({
t: ZodTypes.map,
valueType,
keyType,
});
};
}