Skip to content

Commit 1e8261a

Browse files
achingbrainGozala
andauthored
fix: request body type (#129)
Fixes two problems: 1. The import for `NodeReadableStream` was missing 2. We can't use `NodeReadableStream` as the type for `body` because it it not assignable to any type that makes up `BodyInit` so instead [modify](https://stackoverflow.com/questions/41285211/overriding-interface-property-type-defined-in-typescript-d-ts-file) the RequestInit type to omit the original `body` type and include the new one. Co-authored-by: Irakli Gozalishvili <[email protected]>
1 parent 7fe2ec9 commit 1e8261a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/types.d.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Readable as NodeReadableStream } from 'stream'
2+
13
interface ProgressStatus {
24
total: number
35
loaded: number
@@ -6,7 +8,9 @@ interface ProgressStatus {
68

79
export interface ProgressFn { (status: ProgressStatus): void }
810

9-
export interface FetchOptions extends RequestInit {
11+
type Override<T, R> = Omit<T, keyof R> & R
12+
13+
export type FetchOptions = Override<RequestInit, {
1014
/**
1115
* Extended body with support for node readable stream
1216
*/
@@ -29,7 +33,7 @@ export interface FetchOptions extends RequestInit {
2933
*/
3034
onDownloadProgress?: ProgressFn
3135
overrideMimeType?: string
32-
}
36+
}>
3337

3438
export interface HTTPOptions extends FetchOptions {
3539
json?: any

0 commit comments

Comments
 (0)