viem 0.0.0-w-20230818192605 → 0.0.0-w-20230818230619

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,24 +72,6 @@ export type Or<T extends readonly unknown[],> = T extends readonly [
72
72
  */
73
73
  export type IsUndefined<T> = [undefined] extends [T] ? true : false
74
74
 
75
- /**
76
- * Excludes empty attributes from T if TMaybeExclude is true.
77
- *
78
- * @example
79
- * type Result = MaybeExcludeEmpty<{ a: string, b: number, c: [] }, true>
80
- * // ^? type Result = { a: string, b: number }
81
- * @example
82
- * type Result = MaybeExcludeEmpty<{ a: string, b: number, c: [] }, false>
83
- * // ^? type Result = { a: string, b: number, c: [] }
84
- * @example
85
- * type Result = MaybeExcludeEmpty<{ a: string, b: number, c: undefined }, true>
86
- * // ^? type Result = { a: string, b: number }
87
- */
88
- export type MaybeExcludeEmpty<
89
- T,
90
- TMaybeExclude extends boolean,
91
- > = TMaybeExclude extends true ? Exclude<T, [] | null | undefined> : T
92
-
93
75
  export type MaybePromise<T> = T | Promise<T>
94
76
 
95
77
  /**
@@ -107,24 +89,14 @@ export type MaybeRequired<T, TRequired extends boolean> = TRequired extends true
107
89
  : T
108
90
 
109
91
  /**
110
- * @description Makes the attribute on the type T allow undefined if TUndefinedish is true.
92
+ * @description Assigns the properties of U onto T.
111
93
  *
112
94
  * @example
113
- * MaybeUndefined<string, true>
114
- * => string | undefined
115
- *
116
- * MaybeUndefined<string, false>
117
- * => string
118
- */
119
- export type MaybeUndefined<
120
- T,
121
- TUndefinedish extends boolean,
122
- > = TUndefinedish extends true ? T | undefined : T
123
-
124
- /**
125
- * @private Helper for `Assign`. This is a workaround for tsc generating errorneous type definitions.
95
+ * Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
96
+ * => { a: undefined, b: number, c: boolean }
126
97
  */
127
- export type Assign_<T, U> = {
98
+ export type Assign<T, U> = Assign_<T, U> & U
99
+ type Assign_<T, U> = {
128
100
  [K in
129
101
  keyof T as K extends keyof U
130
102
  ? U[K] extends void
@@ -133,28 +105,6 @@ export type Assign_<T, U> = {
133
105
  : K]: K extends keyof U ? U[K] : T[K]
134
106
  }
135
107
 
136
- /**
137
- * @description Assigns the properties of U onto T.
138
- *
139
- * @example
140
- * Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
141
- * => { a: undefined, b: number, c: boolean }
142
- */
143
- export type Assign<T, U> = Assign_<T, U> & U
144
-
145
- /**
146
- * @description Makes nullable properties from T optional.
147
- *
148
- * @example
149
- * OptionalNullable<{ a: string | undefined, c: number }>
150
- * => { a?: string | undefined, c: number }
151
- */
152
- export type OptionalNullable<T> = {
153
- [K in keyof T as T[K] extends NonNullable<unknown> ? K : never]: T[K]
154
- } & {
155
- [K in keyof T as T[K] extends NonNullable<unknown> ? never : K]?: T[K]
156
- }
157
-
158
108
  /**
159
109
  * @description Make properties K of type T never.
160
110
  *
@@ -185,15 +135,6 @@ export type UnionOmit<T, K extends keyof any> = T extends any
185
135
  ? Omit<T, K>
186
136
  : never
187
137
 
188
- /**
189
- * @description Creates a type that is a partial of T, but with the required keys K.
190
- *
191
- * @example
192
- * PartialBy<{ a: string, b: number }, 'a'>
193
- * => { a?: string, b: number }
194
- */
195
- export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
196
-
197
138
  /**
198
139
  * @description Combines members of an intersection into a readable type.
199
140
  *
@@ -206,34 +147,6 @@ export type Prettify<T> = {
206
147
  [K in keyof T]: T[K]
207
148
  } & {}
208
149
 
209
- type TrimLeft<T, Chars extends string = ' '> = T extends `${Chars}${infer R}`
210
- ? TrimLeft<R>
211
- : T
212
- type TrimRight<T, Chars extends string = ' '> = T extends `${infer R}${Chars}`
213
- ? TrimRight<R>
214
- : T
215
-
216
- /**
217
- * @description Creates a type with required keys K from T.
218
- *
219
- * @example
220
- * type Result = RequiredBy<{ a?: string, b?: number, c: number }, 'a' | 'c'>
221
- * // ^? { a: string, b?: number, c: number }
222
- */
223
- export type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
224
-
225
- /**
226
- * @description Trims empty space from type T.
227
- *
228
- * @example
229
- * Trim<' lol '>
230
- * => 'lol'
231
- */
232
- export type Trim<T, Chars extends string = ' '> = TrimLeft<
233
- TrimRight<T, Chars>,
234
- Chars
235
- >
236
-
237
150
  /**
238
151
  * @description Creates a type that extracts the values of T.
239
152
  *
@@ -270,7 +183,7 @@ export type IsUnion<
270
183
  export type MaybePartial<
271
184
  type,
272
185
  enabled extends boolean | undefined,
273
- > = enabled extends true ? ExactPartial<type> : type
186
+ > = enabled extends true ? Prettify<ExactPartial<type>> : type
274
187
 
275
188
  export type ExactPartial<type> = {
276
189
  [key in keyof type]?: type[key] | undefined