@zimic/http 0.4.0-canary.1 → 0.4.0-canary.3

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.
@@ -50,61 +50,55 @@ export namespace HttpFormDataSchemaName {
50
50
  */
51
51
  export type HttpFormDataSchemaName<Schema extends HttpFormDataSchema> = IfNever<Schema, never, keyof Schema & string>;
52
52
 
53
- type PrimitiveHttpFormDataSerialized<Type> = Type extends HttpFormDataSchema[string]
54
- ? Type
55
- : Type extends (infer ArrayItem)[]
56
- ? ArrayItem extends (infer _InternalArrayItem)[]
57
- ? never
58
- : PrimitiveHttpFormDataSerialized<ArrayItem>[]
59
- : Type extends number
60
- ? `${number}`
61
- : Type extends boolean
62
- ? `${boolean}`
63
- : never;
53
+ type PrimitiveHttpFormDataSerialized<Type> = [Type] extends [never]
54
+ ? never
55
+ : Type extends number
56
+ ? `${number}`
57
+ : Type extends boolean
58
+ ? `${boolean}`
59
+ : Type extends null
60
+ ? 'null'
61
+ : Type extends symbol
62
+ ? never
63
+ : Type extends HttpFormDataSchema[string]
64
+ ? Type
65
+ : Type extends (infer ArrayItem)[]
66
+ ? ArrayItem extends (infer _InternalArrayItem)[]
67
+ ? never
68
+ : PrimitiveHttpFormDataSerialized<ArrayItem>[]
69
+ : string;
64
70
 
65
71
  /**
66
72
  * Recursively converts a schema to its {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}-serialized
67
- * version. Numbers and booleans are converted to `${number}` and `${boolean}` respectively, and not serializable values
68
- * are excluded, such as functions and dates.
73
+ * version. Numbers, booleans, and null are converted to `${number}`, `${boolean}`, and 'null' respectively, and other
74
+ * values become strings.
69
75
  *
70
76
  * @example
71
77
  * import { type HttpFormDataSerialized } from '@zimic/http';
72
78
  *
73
79
  * type Schema = HttpFormDataSerialized<{
74
- * contentTitle: string | null;
75
- * contentSize: number;
80
+ * contentTitle: string;
81
+ * contentSize: number | null;
76
82
  * content: Blob;
77
83
  * full?: boolean;
78
- * date: Date;
79
- * method: () => void;
80
84
  * }>;
81
85
  * // {
82
- * // contentTitle: string | null;
83
- * // contentSize? `${number}`;
86
+ * // contentTitle: string;
87
+ * // contentSize? `${number}` | 'null';
84
88
  * // content: Blob;
85
89
  * // full?: "false" | "true";
86
90
  * // }
87
91
  */
88
- export type HttpFormDataSerialized<Type> = Type extends HttpFormDataSchema
89
- ? Type
90
- : Type extends (infer _ArrayItem)[]
91
- ? never
92
- : Type extends Date
93
- ? never
94
- : Type extends (...parameters: never[]) => unknown
95
- ? never
96
- : Type extends symbol
97
- ? never
98
- : Type extends Map<infer _Key, infer _Value>
99
- ? never
100
- : Type extends Set<infer _Value>
101
- ? never
102
- : Type extends object
103
- ? {
104
- [Key in keyof Type as IfNever<
105
- PrimitiveHttpFormDataSerialized<Type[Key]>,
106
- never,
107
- Key
108
- >]: PrimitiveHttpFormDataSerialized<Type[Key]>;
109
- }
110
- : never;
92
+ export type HttpFormDataSerialized<Type> = [Type] extends [never]
93
+ ? never
94
+ : Type extends HttpFormDataSchema
95
+ ? Type
96
+ : Type extends object
97
+ ? {
98
+ [Key in keyof Type as IfNever<
99
+ PrimitiveHttpFormDataSerialized<Type[Key]>,
100
+ never,
101
+ Key
102
+ >]: PrimitiveHttpFormDataSerialized<Type[Key]>;
103
+ }
104
+ : never;
@@ -15,9 +15,6 @@ function pickPrimitiveProperties<LooseSchema extends HttpHeadersSchema.Loose>(sc
15
15
  * An extended HTTP headers object with a strictly-typed schema. Fully compatible with the built-in
16
16
  * {@link https://developer.mozilla.org/docs/Web/API/Headers `Headers`} class.
17
17
  *
18
- * **IMPORTANT**: the input of `HttpHeaders` and all of its internal types must be declared inline or as a type aliases
19
- * (`type`). They cannot be interfaces.
20
- *
21
18
  * @example
22
19
  * import { HttpHeaders } from '@zimic/http';
23
20
  *
@@ -34,10 +31,9 @@ function pickPrimitiveProperties<LooseSchema extends HttpHeadersSchema.Loose>(sc
34
31
  *
35
32
  * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders` API reference}
36
33
  */
37
- class HttpHeaders<
38
- LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose,
39
- Schema extends HttpHeadersSchema = HttpHeadersSerialized<LooseSchema>,
40
- > extends Headers {
34
+ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> extends Headers {
35
+ readonly _schema!: HttpHeadersSerialized<LooseSchema>;
36
+
41
37
  constructor(init?: HttpHeadersInit<LooseSchema>) {
42
38
  if (init instanceof Headers || Array.isArray(init) || !init) {
43
39
  super(init);
@@ -47,38 +43,40 @@ class HttpHeaders<
47
43
  }
48
44
 
49
45
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */
50
- set<Name extends HttpHeadersSchemaName<Schema>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
46
+ set<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
51
47
  super.set(name, value);
52
48
  }
53
49
 
54
50
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */
55
- append<Name extends HttpHeadersSchemaName<Schema>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
51
+ append<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
56
52
  super.append(name, value);
57
53
  }
58
54
 
59
55
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */
60
- get<Name extends HttpHeadersSchemaName<Schema>>(name: Name): ReplaceBy<Schema[Name], undefined, null> {
61
- return super.get(name) as ReplaceBy<Schema[Name], undefined, null>;
56
+ get<Name extends HttpHeadersSchemaName<this['_schema']>>(
57
+ name: Name,
58
+ ): ReplaceBy<this['_schema'][Name], undefined, null> {
59
+ return super.get(name) as never;
62
60
  }
63
61
 
64
62
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
65
- getSetCookie(): NonNullable<Default<Schema['Set-Cookie'], string>>[] {
66
- return super.getSetCookie() as NonNullable<Default<Schema['Set-Cookie'], string>>[];
63
+ getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {
64
+ return super.getSetCookie() as never;
67
65
  }
68
66
 
69
67
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
70
- has<Name extends HttpHeadersSchemaName<Schema>>(name: Name): boolean {
68
+ has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {
71
69
  return super.has(name);
72
70
  }
73
71
 
74
72
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */
75
- delete<Name extends HttpHeadersSchemaName<Schema>>(name: Name): void {
73
+ delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {
76
74
  super.delete(name);
77
75
  }
78
76
 
79
- forEach<This extends HttpHeaders<Schema>>(
80
- callback: <Key extends HttpHeadersSchemaName<Schema>>(
81
- value: NonNullable<Schema[Key]> & string,
77
+ forEach<This extends HttpHeaders<this['_schema']>>(
78
+ callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(
79
+ value: NonNullable<this['_schema'][Key]> & string,
82
80
  key: Key,
83
81
  parent: Headers,
84
82
  ) => void,
@@ -88,30 +86,32 @@ class HttpHeaders<
88
86
  }
89
87
 
90
88
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */
91
- keys(): HeadersIterator<HttpHeadersSchemaName<Schema>> {
92
- return super.keys() as HeadersIterator<HttpHeadersSchemaName<Schema>>;
89
+ keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {
90
+ return super.keys() as never;
93
91
  }
94
92
 
95
93
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */
96
- values(): HeadersIterator<NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string> {
97
- return super.values() as HeadersIterator<NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string>;
94
+ values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {
95
+ return super.values() as never;
98
96
  }
99
97
 
100
98
  /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */
101
99
  entries(): HeadersIterator<
102
- [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]
100
+ [
101
+ HttpHeadersSchemaName<this['_schema']>,
102
+ NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string,
103
+ ]
103
104
  > {
104
- return super.entries() as HeadersIterator<
105
- [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]
106
- >;
105
+ return super.entries() as never;
107
106
  }
108
107
 
109
108
  [Symbol.iterator](): HeadersIterator<
110
- [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]
109
+ [
110
+ HttpHeadersSchemaName<this['_schema']>,
111
+ NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string,
112
+ ]
111
113
  > {
112
- return super[Symbol.iterator]() as HeadersIterator<
113
- [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]
114
- >;
114
+ return super[Symbol.iterator]() as never;
115
115
  }
116
116
 
117
117
  /**
@@ -183,8 +183,8 @@ class HttpHeaders<
183
183
  *
184
184
  * @returns A plain object representation of these headers.
185
185
  */
186
- toObject(): Schema {
187
- const object = {} as Schema;
186
+ toObject(): this['_schema'] {
187
+ const object = {} as this['_schema'];
188
188
 
189
189
  for (const [key, value] of this.entries()) {
190
190
  object[key] = value;
@@ -10,21 +10,22 @@ export namespace HttpPathParamsSchema {
10
10
  export type Loose = Record<string, any>;
11
11
  }
12
12
 
13
- type PrimitiveHttpPathParamsSerialized<Type> = Type extends HttpPathParamsSchema[string]
14
- ? Type
15
- : Type extends (infer _ArrayItem)[]
16
- ? never
17
- : Type extends number
18
- ? `${number}`
19
- : Type extends boolean
20
- ? `${boolean}`
21
- : Type extends null
22
- ? undefined
23
- : never;
13
+ type PrimitiveHttpPathParamsSerialized<Type> = [Type] extends [never]
14
+ ? never
15
+ : Type extends number
16
+ ? `${number}`
17
+ : Type extends boolean
18
+ ? `${boolean}`
19
+ : Type extends null
20
+ ? 'null'
21
+ : Type extends symbol
22
+ ? never
23
+ : Type extends HttpPathParamsSchema[string]
24
+ ? Type
25
+ : string;
24
26
  /**
25
- * Recursively converts a schema to its path parameters-serialized version. Numbers and booleans are converted to
26
- * `${number}` and `${boolean}` respectively, null becomes undefined and not serializable values are excluded, such as
27
- * functions and dates.
27
+ * Recursively converts a schema to its path parameters-serialized version. Numbers, booleans, and null are converted to
28
+ * `${number}`, `${boolean}`, and 'null' respectively, and other values become strings.
28
29
  *
29
30
  * @example
30
31
  * import { type HttpPathParamsSerialized } from '@zimic/http';
@@ -33,35 +34,23 @@ type PrimitiveHttpPathParamsSerialized<Type> = Type extends HttpPathParamsSchema
33
34
  * userId: string;
34
35
  * notificationId: number | null;
35
36
  * full?: boolean;
36
- * from?: Date;
37
- * method: () => void;
38
37
  * }>;
39
38
  * // {
40
39
  * // userId: string;
41
- * // notificationId: `${number}` | undefined;
40
+ * // notificationId: `${number}` | 'null';
42
41
  * // full?: "false" | "true";
43
42
  * // }
44
43
  */
45
- export type HttpPathParamsSerialized<Type> = Type extends HttpPathParamsSchema
46
- ? Type
47
- : Type extends (infer _ArrayItem)[]
48
- ? never
49
- : Type extends Date
50
- ? never
51
- : Type extends (...parameters: never[]) => unknown
52
- ? never
53
- : Type extends symbol
54
- ? never
55
- : Type extends Map<infer _Key, infer _Value>
56
- ? never
57
- : Type extends Set<infer _Value>
58
- ? never
59
- : Type extends object
60
- ? {
61
- [Key in keyof Type as IfNever<
62
- PrimitiveHttpPathParamsSerialized<Type[Key]>,
63
- never,
64
- Key
65
- >]: PrimitiveHttpPathParamsSerialized<Type[Key]>;
66
- }
67
- : never;
44
+ export type HttpPathParamsSerialized<Type> = [Type] extends [never]
45
+ ? never
46
+ : Type extends HttpPathParamsSchema
47
+ ? Type
48
+ : Type extends object
49
+ ? {
50
+ [Key in keyof Type as IfNever<
51
+ PrimitiveHttpPathParamsSerialized<Type[Key]>,
52
+ never,
53
+ Key
54
+ >]: PrimitiveHttpPathParamsSerialized<Type[Key]>;
55
+ }
56
+ : never;
@@ -24,9 +24,6 @@ function pickPrimitiveProperties<Schema extends HttpSearchParamsSchema.Loose>(sc
24
24
  * An extended HTTP search params object with a strictly-typed schema. Fully compatible with the built-in
25
25
  * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams `URLSearchParams`} class.
26
26
  *
27
- * **IMPORTANT**: the input of `HttpSearchParams` and all of its internal types must be declared inline or as a type
28
- * aliases (`type`). They cannot be interfaces.
29
- *
30
27
  * @example
31
28
  * import { HttpSearchParams } from '@zimic/http';
32
29
  *
@@ -48,8 +45,9 @@ function pickPrimitiveProperties<Schema extends HttpSearchParamsSchema.Loose>(sc
48
45
  */
49
46
  class HttpSearchParams<
50
47
  LooseSchema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose,
51
- Schema extends HttpSearchParamsSchema = HttpSearchParamsSerialized<LooseSchema>,
52
48
  > extends URLSearchParams {
49
+ readonly _schema!: HttpSearchParamsSerialized<LooseSchema>;
50
+
53
51
  constructor(init?: HttpSearchParamsInit<LooseSchema>) {
54
52
  if (init instanceof URLSearchParams || Array.isArray(init) || typeof init === 'string' || !init) {
55
53
  super(init);
@@ -70,7 +68,7 @@ class HttpSearchParams<
70
68
  }
71
69
 
72
70
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */
73
- set<Name extends HttpSearchParamsSchemaName<Schema>>(
71
+ set<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
74
72
  name: Name,
75
73
  value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
76
74
  ): void {
@@ -78,7 +76,7 @@ class HttpSearchParams<
78
76
  }
79
77
 
80
78
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */
81
- append<Name extends HttpSearchParamsSchemaName<Schema>>(
79
+ append<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
82
80
  name: Name,
83
81
  value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
84
82
  ): void {
@@ -94,10 +92,10 @@ class HttpSearchParams<
94
92
  * @returns The value associated with the key name, or `null` if the key does not exist.
95
93
  * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}
96
94
  */
97
- get<Name extends HttpSearchParamsSchemaName.NonArray<Schema>>(
95
+ get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(
98
96
  name: Name,
99
- ): ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null> {
100
- return super.get(name) as ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null>;
97
+ ): ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {
98
+ return super.get(name) as never;
101
99
  }
102
100
 
103
101
  /**
@@ -109,14 +107,14 @@ class HttpSearchParams<
109
107
  * @returns An array of values associated with the key name, or an empty array if the key does not exist.
110
108
  * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}
111
109
  */
112
- getAll<Name extends HttpSearchParamsSchemaName.Array<Schema>>(
110
+ getAll<Name extends HttpSearchParamsSchemaName.Array<this['_schema']>>(
113
111
  name: Name,
114
- ): ArrayItemIfArray<NonNullable<Schema[Name]>>[] {
115
- return super.getAll(name) as ArrayItemIfArray<NonNullable<Schema[Name]>>[];
112
+ ): ArrayItemIfArray<NonNullable<this['_schema'][Name]>>[] {
113
+ return super.getAll(name) as never;
116
114
  }
117
115
 
118
116
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */
119
- has<Name extends HttpSearchParamsSchemaName<Schema>>(
117
+ has<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
120
118
  name: Name,
121
119
  value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
122
120
  ): boolean {
@@ -124,18 +122,18 @@ class HttpSearchParams<
124
122
  }
125
123
 
126
124
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */
127
- delete<Name extends HttpSearchParamsSchemaName<Schema>>(
125
+ delete<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
128
126
  name: Name,
129
127
  value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
130
128
  ): void {
131
129
  super.delete(name, value);
132
130
  }
133
131
 
134
- forEach<This extends HttpSearchParams<Schema>>(
135
- callback: <Key extends HttpSearchParamsSchemaName<Schema>>(
136
- value: ArrayItemIfArray<NonNullable<Schema[Key]>>,
132
+ forEach<This extends HttpSearchParams<this['_schema']>>(
133
+ callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(
134
+ value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>,
137
135
  key: Key,
138
- parent: HttpSearchParams<Schema>,
136
+ parent: HttpSearchParams<this['_schema']>,
139
137
  ) => void,
140
138
  thisArg?: This,
141
139
  ): void {
@@ -143,32 +141,34 @@ class HttpSearchParams<
143
141
  }
144
142
 
145
143
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */
146
- keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<Schema>> {
147
- return super.keys() as URLSearchParamsIterator<HttpSearchParamsSchemaName<Schema>>;
144
+ keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {
145
+ return super.keys() as never;
148
146
  }
149
147
 
150
148
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */
151
- values(): URLSearchParamsIterator<ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>> {
152
- return super.values() as URLSearchParamsIterator<
153
- ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>
154
- >;
149
+ values(): URLSearchParamsIterator<
150
+ ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>
151
+ > {
152
+ return super.values() as never;
155
153
  }
156
154
 
157
155
  /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */
158
156
  entries(): URLSearchParamsIterator<
159
- [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]
157
+ [
158
+ HttpSearchParamsSchemaName<this['_schema']>,
159
+ ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>,
160
+ ]
160
161
  > {
161
- return super.entries() as URLSearchParamsIterator<
162
- [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]
163
- >;
162
+ return super.entries() as never;
164
163
  }
165
164
 
166
165
  [Symbol.iterator](): URLSearchParamsIterator<
167
- [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]
166
+ [
167
+ HttpSearchParamsSchemaName<this['_schema']>,
168
+ ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>,
169
+ ]
168
170
  > {
169
- return super[Symbol.iterator]() as URLSearchParamsIterator<
170
- [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]
171
- >;
171
+ return super[Symbol.iterator]() as never;
172
172
  }
173
173
 
174
174
  /**
@@ -227,13 +227,13 @@ class HttpSearchParams<
227
227
  * @returns A plain object representation of these search params.
228
228
  */
229
229
  toObject() {
230
- const object = {} as Schema;
230
+ const object = {} as this['_schema'];
231
231
 
232
- type SchemaValue = Schema[HttpSearchParamsSchemaName<Schema>];
232
+ type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];
233
233
 
234
234
  for (const [key, value] of this.entries()) {
235
235
  if (key in object) {
236
- const existingValue = object[key];
236
+ const existingValue = object[key] as SchemaValue[];
237
237
 
238
238
  if (Array.isArray<SchemaValue>(existingValue)) {
239
239
  existingValue.push(value as SchemaValue);
@@ -72,62 +72,56 @@ export type HttpSearchParamsSchemaName<Schema extends HttpSearchParamsSchema> =
72
72
  keyof Schema & string
73
73
  >;
74
74
 
75
- type PrimitiveHttpSearchParamsSerialized<Type> = Type extends HttpSearchParamsSchema[string]
76
- ? Type
77
- : Type extends (infer ArrayItem)[]
78
- ? ArrayItem extends (infer _InternalArrayItem)[]
79
- ? never
80
- : PrimitiveHttpSearchParamsSerialized<ArrayItem>[]
81
- : Type extends number
82
- ? `${number}`
83
- : Type extends boolean
84
- ? `${boolean}`
85
- : Type extends null
86
- ? undefined
87
- : never;
75
+ type PrimitiveHttpSearchParamsSerialized<Type> = [Type] extends [never]
76
+ ? never
77
+ : Type extends number
78
+ ? `${number}`
79
+ : Type extends boolean
80
+ ? `${boolean}`
81
+ : Type extends null
82
+ ? 'null'
83
+ : Type extends symbol
84
+ ? never
85
+ : Type extends HttpSearchParamsSchema[string]
86
+ ? Type
87
+ : Type extends (infer ArrayItem)[]
88
+ ? ArrayItem extends (infer _InternalArrayItem)[]
89
+ ? string
90
+ : PrimitiveHttpSearchParamsSerialized<ArrayItem>[]
91
+ : string;
88
92
 
89
93
  /**
90
94
  * Recursively converts a schema to its
91
- * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams URLSearchParams}-serialized version. Numbers and
92
- * booleans are converted to `${number}` and `${boolean}` respectively, null becomes undefined and not serializable
93
- * values are excluded, such as functions and dates.
95
+ * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams URLSearchParams}-serialized version. Numbers,
96
+ * booleans, and null are converted to `${number}`, `${boolean}`, and 'null' respectively, and other values become
97
+ * strings.
94
98
  *
95
99
  * @example
96
100
  * import { type HttpSearchParamsSerialized } from '@zimic/http';
97
101
  *
98
102
  * type Params = HttpSearchParamsSerialized<{
99
- * query: string | null;
103
+ * query?: string;
104
+ * order: 'asc' | 'desc' | null;
100
105
  * page?: number;
101
106
  * full?: boolean;
102
- * date: Date;
103
- * method: () => void;
104
107
  * }>;
105
108
  * // {
106
- * // query: string | undefined;
109
+ * // query?: string;
110
+ * // order: 'asc' | 'desc' | 'null';
107
111
  * // page?: `${number}`;
108
112
  * // full?: "false" | "true";
109
113
  * // }
110
114
  */
111
- export type HttpSearchParamsSerialized<Type> = Type extends HttpSearchParamsSchema
112
- ? Type
113
- : Type extends (infer _ArrayItem)[]
114
- ? never
115
- : Type extends Date
116
- ? never
117
- : Type extends (...parameters: never[]) => unknown
118
- ? never
119
- : Type extends symbol
120
- ? never
121
- : Type extends Map<infer _Key, infer _Value>
122
- ? never
123
- : Type extends Set<infer _Value>
124
- ? never
125
- : Type extends object
126
- ? {
127
- [Key in keyof Type as IfNever<
128
- PrimitiveHttpSearchParamsSerialized<Type[Key]>,
129
- never,
130
- Key
131
- >]: PrimitiveHttpSearchParamsSerialized<Type[Key]>;
132
- }
133
- : never;
115
+ export type HttpSearchParamsSerialized<Type> = [Type] extends [never]
116
+ ? never
117
+ : Type extends HttpSearchParamsSchema
118
+ ? Type
119
+ : Type extends object
120
+ ? {
121
+ [Key in keyof Type as IfNever<
122
+ PrimitiveHttpSearchParamsSerialized<Type[Key]>,
123
+ never,
124
+ Key
125
+ >]: PrimitiveHttpSearchParamsSerialized<Type[Key]>;
126
+ }
127
+ : never;