@@ -50,7 +50,7 @@ abstract class FetchConnection<T extends ConnectionType>
5050 async send (
5151 url : string ,
5252 method : string ,
53- body ?: ArrayBufferView | Blob | string ,
53+ body ?: NodeJS . ArrayBufferView | Blob | string ,
5454 headers ?: Record < string , string >
5555 ) : Promise < void > {
5656 if ( this . sent_ ) {
@@ -62,7 +62,7 @@ abstract class FetchConnection<T extends ConnectionType>
6262 const response = await this . fetch_ ( url , {
6363 method,
6464 headers : headers || { } ,
65- body : body as ArrayBufferView | string
65+ body : body as NodeJS . ArrayBufferView | string
6666 } ) ;
6767 this . headers_ = response . headers ;
6868 this . statusCode_ = response . status ;
@@ -146,13 +146,15 @@ export function newBytesConnection(): Connection<ArrayBuffer> {
146146 return new FetchBytesConnection ( ) ;
147147}
148148
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 ;
151153
152154 async send (
153155 url : string ,
154156 method : string ,
155- body ?: ArrayBufferView | Blob | string ,
157+ body ?: NodeJS . ArrayBufferView | Blob | string ,
156158 headers ?: Record < string , string >
157159 ) : Promise < void > {
158160 if ( this . sent_ ) {
@@ -164,12 +166,12 @@ export class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream
164166 const response = await this . fetch_ ( url , {
165167 method,
166168 headers : headers || { } ,
167- body : body as ArrayBufferView | string
169+ body : body as NodeJS . ArrayBufferView | string
168170 } ) ;
169171 this . headers_ = response . headers ;
170172 this . statusCode_ = response . status ;
171173 this . errorCode_ = ErrorCode . NO_ERROR ;
172- this . stream_ = response . body ;
174+ this . stream_ = response . body as ReadableStream < Uint8Array > ;
173175 } catch ( e ) {
174176 this . errorText_ = ( e as Error ) ?. message ;
175177 // emulate XHR which sets status to 0 when encountering a network error
@@ -178,15 +180,15 @@ export class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream
178180 }
179181 }
180182
181- getResponse ( ) : NodeJS . ReadableStream {
183+ getResponse ( ) : ReadableStream {
182184 if ( ! this . stream_ ) {
183185 throw internalError ( 'cannot .getResponse() before sending' ) ;
184186 }
185187 return this . stream_ ;
186188 }
187189}
188190
189- export function newStreamConnection ( ) : Connection < NodeJS . ReadableStream > {
191+ export function newStreamConnection ( ) : Connection < ReadableStream < Uint8Array > > {
190192 return new FetchStreamConnection ( ) ;
191193}
192194
0 commit comments