Skip to content

Commit abe9163

Browse files
committed
♻️ Update object.entries types internally
1 parent 99dde11 commit abe9163

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

env.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface ObjectConstructor {
2+
entries<K extends string | number, V>(o: Record<K, V>): Array<[`${K}`, V]>
3+
}

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="../env.d.ts" />
2+
13
interface SearchParams extends Record<string, any> {}
24

35
interface Payload {
@@ -257,16 +259,14 @@ function request<P extends Payload>(
257259
.then(options.onResponse)
258260
.then(options.onSuccess, options.onFailure) as ResponsePromise<P>
259261

260-
for (const [key, value] of Object.entries(CONTENT_TYPES) as Array<
261-
[keyof BodyMethods, string]
262-
>) {
262+
Object.entries(CONTENT_TYPES).forEach(([key, value]) => {
263263
promise[key] = () => {
264264
options.headers.set('accept', value)
265265
return promise
266266
.then((result) => (key === 'void' ? undefined : result.clone()[key]()))
267267
.then((parsed) => (key === 'json' ? options.onJSON(parsed) : parsed))
268268
}
269-
}
269+
})
270270

271271
return promise
272272
}

0 commit comments

Comments
 (0)