Skip to content

Commit

Permalink
fix: fix .pick(), .omit() generic Type
Browse files Browse the repository at this point in the history
  • Loading branch information
petrovmiroslav committed Feb 19, 2024
1 parent 76c8ace commit 8d364f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions deno/lib/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export namespace util {
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
export type MakePartial<T, K extends keyof T> = Omit<T, K> &
Partial<Pick<T, K>>;
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;

export const arrayToEnum = <T extends string, U extends [T, ...T[]]>(
items: U
Expand Down
4 changes: 2 additions & 2 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@ export class ZodObject<
}) as any;
}

pick<Mask extends { [k in keyof T]?: true }>(
pick<Mask extends util.Exactly<{ [k in keyof T]?: true }, Mask>>(
mask: Mask
): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall> {
const shape: any = {};
Expand All @@ -2591,7 +2591,7 @@ export class ZodObject<
}) as any;
}

omit<Mask extends { [k in keyof T]?: true }>(
omit<Mask extends util.Exactly<{ [k in keyof T]?: true }, Mask>>(
mask: Mask
): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall> {
const shape: any = {};
Expand Down
1 change: 1 addition & 0 deletions src/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export namespace util {
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
export type MakePartial<T, K extends keyof T> = Omit<T, K> &
Partial<Pick<T, K>>;
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;

export const arrayToEnum = <T extends string, U extends [T, ...T[]]>(
items: U
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@ export class ZodObject<
}) as any;
}

pick<Mask extends { [k in keyof T]?: true }>(
pick<Mask extends util.Exactly<{ [k in keyof T]?: true }, Mask>>(
mask: Mask
): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall> {
const shape: any = {};
Expand All @@ -2591,7 +2591,7 @@ export class ZodObject<
}) as any;
}

omit<Mask extends { [k in keyof T]?: true }>(
omit<Mask extends util.Exactly<{ [k in keyof T]?: true }, Mask>>(
mask: Mask
): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall> {
const shape: any = {};
Expand Down

0 comments on commit 8d364f0

Please sign in to comment.