@@ -50,7 +50,7 @@ abstract class FetchConnection<T extends ConnectionType>
50
50
async send (
51
51
url : string ,
52
52
method : string ,
53
- body ?: ArrayBufferView | Blob | string ,
53
+ body ?: NodeJS . ArrayBufferView | Blob | string ,
54
54
headers ?: Record < string , string >
55
55
) : Promise < void > {
56
56
if ( this . sent_ ) {
@@ -62,7 +62,7 @@ abstract class FetchConnection<T extends ConnectionType>
62
62
const response = await this . fetch_ ( url , {
63
63
method,
64
64
headers : headers || { } ,
65
- body : body as ArrayBufferView | string
65
+ body : body as NodeJS . ArrayBufferView | string
66
66
} ) ;
67
67
this . headers_ = response . headers ;
68
68
this . statusCode_ = response . status ;
@@ -146,13 +146,15 @@ export function newBytesConnection(): Connection<ArrayBuffer> {
146
146
return new FetchBytesConnection ( ) ;
147
147
}
148
148
149
- export class FetchStreamConnection extends FetchConnection < NodeJS . ReadableStream > {
150
- private stream_ : NodeJS . ReadableStream | null = null ;
149
+ export class FetchStreamConnection extends FetchConnection <
150
+ ReadableStream < Uint8Array >
151
+ > {
152
+ private stream_ : ReadableStream < Uint8Array > | null = null ;
151
153
152
154
async send (
153
155
url : string ,
154
156
method : string ,
155
- body ?: ArrayBufferView | Blob | string ,
157
+ body ?: NodeJS . ArrayBufferView | Blob | string ,
156
158
headers ?: Record < string , string >
157
159
) : Promise < void > {
158
160
if ( this . sent_ ) {
@@ -164,12 +166,12 @@ export class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream
164
166
const response = await this . fetch_ ( url , {
165
167
method,
166
168
headers : headers || { } ,
167
- body : body as ArrayBufferView | string
169
+ body : body as NodeJS . ArrayBufferView | string
168
170
} ) ;
169
171
this . headers_ = response . headers ;
170
172
this . statusCode_ = response . status ;
171
173
this . errorCode_ = ErrorCode . NO_ERROR ;
172
- this . stream_ = response . body ;
174
+ this . stream_ = response . body as ReadableStream < Uint8Array > ;
173
175
} catch ( e ) {
174
176
this . errorText_ = ( e as Error ) ?. message ;
175
177
// emulate XHR which sets status to 0 when encountering a network error
@@ -178,15 +180,15 @@ export class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream
178
180
}
179
181
}
180
182
181
- getResponse ( ) : NodeJS . ReadableStream {
183
+ getResponse ( ) : ReadableStream {
182
184
if ( ! this . stream_ ) {
183
185
throw internalError ( 'cannot .getResponse() before sending' ) ;
184
186
}
185
187
return this . stream_ ;
186
188
}
187
189
}
188
190
189
- export function newStreamConnection ( ) : Connection < NodeJS . ReadableStream > {
191
+ export function newStreamConnection ( ) : Connection < ReadableStream < Uint8Array > > {
190
192
return new FetchStreamConnection ( ) ;
191
193
}
192
194
0 commit comments