util.d.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. export declare namespace util {
  2. type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
  3. export type isAny<T> = 0 extends 1 & T ? true : false;
  4. export const assertEqual: <A, B>(val: AssertEqual<A, B>) => AssertEqual<A, B>;
  5. export function assertIs<T>(_arg: T): void;
  6. export function assertNever(_x: never): never;
  7. export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
  8. export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
  9. export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
  10. export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
  11. export const getValidEnumValues: (obj: any) => any[];
  12. export const objectValues: (obj: any) => any[];
  13. export const objectKeys: ObjectConstructor["keys"];
  14. export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
  15. export type identity<T> = objectUtil.identity<T>;
  16. export type flatten<T> = objectUtil.flatten<T>;
  17. export type noUndefined<T> = T extends undefined ? never : T;
  18. export const isInteger: NumberConstructor["isInteger"];
  19. export function joinValues<T extends any[]>(array: T, separator?: string): string;
  20. export const jsonStringifyReplacer: (_: string, value: any) => any;
  21. export {};
  22. }
  23. export declare namespace objectUtil {
  24. export type MergeShapes<U, V> = {
  25. [k in Exclude<keyof U, keyof V>]: U[k];
  26. } & V;
  27. type requiredKeys<T extends object> = {
  28. [k in keyof T]: undefined extends T[k] ? never : k;
  29. }[keyof T];
  30. export type addQuestionMarks<T extends object, R extends keyof T = requiredKeys<T>> = Pick<Required<T>, R> & Partial<T>;
  31. export type identity<T> = T;
  32. export type flatten<T> = identity<{
  33. [k in keyof T]: T[k];
  34. }>;
  35. export type noNeverKeys<T> = {
  36. [k in keyof T]: [T[k]] extends [never] ? never : k;
  37. }[keyof T];
  38. export type noNever<T> = identity<{
  39. [k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
  40. }>;
  41. export const mergeShapes: <U, T>(first: U, second: T) => T & U;
  42. export type extendShape<A, B> = flatten<Omit<A, keyof B> & B>;
  43. export {};
  44. }
  45. export declare const ZodParsedType: {
  46. function: "function";
  47. number: "number";
  48. string: "string";
  49. nan: "nan";
  50. integer: "integer";
  51. float: "float";
  52. boolean: "boolean";
  53. date: "date";
  54. bigint: "bigint";
  55. symbol: "symbol";
  56. undefined: "undefined";
  57. null: "null";
  58. array: "array";
  59. object: "object";
  60. unknown: "unknown";
  61. promise: "promise";
  62. void: "void";
  63. never: "never";
  64. map: "map";
  65. set: "set";
  66. };
  67. export declare type ZodParsedType = keyof typeof ZodParsedType;
  68. export declare const getParsedType: (data: any) => ZodParsedType;