Skip to content

Commit

Permalink
revert fa78e13da13be99a111fbdfa778541b668dd2777.
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov committed Dec 16, 2022
1 parent 2ae29c7 commit 8936547
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 3 additions & 5 deletions deno/lib/types.ts
Expand Up @@ -1881,11 +1881,9 @@ export type SomeZodObject = ZodObject<

export type objectKeyMask<Obj> = { [k in keyof Obj]?: true };

export type optionalPickWith<Obj, Shape> = {} extends Obj
? never
: {
[k in keyof Obj]?: k extends keyof Shape ? Obj[k] : never;
};
export type optionalPickWith<Obj, Shape> = {
[k in keyof Obj]?: k extends keyof Shape ? Obj[k] : never;
};

function deepPartialify(schema: ZodTypeAny): any {
if (schema instanceof ZodObject) {
Expand Down
8 changes: 3 additions & 5 deletions src/types.ts
Expand Up @@ -1881,11 +1881,9 @@ export type SomeZodObject = ZodObject<

export type objectKeyMask<Obj> = { [k in keyof Obj]?: true };

export type optionalPickWith<Obj, Shape> = {} extends Obj
? never
: {
[k in keyof Obj]?: k extends keyof Shape ? Obj[k] : never;
};
export type optionalPickWith<Obj, Shape> = {
[k in keyof Obj]?: k extends keyof Shape ? Obj[k] : never;
};

function deepPartialify(schema: ZodTypeAny): any {
if (schema instanceof ZodObject) {
Expand Down
4 changes: 0 additions & 4 deletions test-d/object.test-d.ts
Expand Up @@ -17,7 +17,6 @@ function testPick() {
schema.pick(mask)
);

expectError(schema.pick({}));
expectError(schema.pick({ NOT_A_MEMBER: true }));
expectError(schema.pick({ hello: true, NOT_A_MEMBER: true }));
expectError(schema.pick({ hello: true, foo: true, NOT_A_MEMBER: true }));
Expand All @@ -31,7 +30,6 @@ function testOmit() {
const mask = { foo: true } as const;
expectType<z.ZodObject<{ hello: z.ZodLiteral<"world!"> }>>(schema.omit(mask));

expectError(schema.omit({}));
expectError(schema.omit({ NOT_A_MEMBER: true }));
expectError(schema.omit({ hello: true, NOT_A_MEMBER: true }));
expectError(schema.omit({ hello: true, foo: true, NOT_A_MEMBER: true }));
Expand All @@ -51,7 +49,6 @@ function testPartial() {
}>
>(schema.partial({ hello: true }));

expectError(schema.partial({}));
expectError(schema.partial({ NOT_A_MEMBER: true }));
expectError(schema.partial({ hello: true, NOT_A_MEMBER: true }));
expectError(schema.partial({ hello: true, foo: true, NOT_A_MEMBER: true }));
Expand All @@ -65,7 +62,6 @@ function testRequired() {
z.ZodObject<{ hello: z.ZodLiteral<"world!">; foo: z.ZodLiteral<"bar"> }>
>(schema.required({ foo: true }));

expectError(schema.required({}));
expectError(schema.required({ NOT_A_MEMBER: true }));
expectError(schema.required({ hello: true, NOT_A_MEMBER: true }));
expectError(schema.required({ hello: true, foo: true, NOT_A_MEMBER: true }));
Expand Down

0 comments on commit 8936547

Please sign in to comment.