Skip to content

Commit eb00eff

Browse files
committed
add type declare for response data when http code not ok
1 parent 558702b commit eb00eff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,19 @@ export declare namespace httpc {
528528
urllibOptions: RequestOptions;
529529
}
530530

531+
// responseWrapper.js
531532
interface ResponseWrapperOptions<T = any> {
532533
data: T;
533534
resp: IncomingMessage;
534535
}
535536

536-
// responseWrapper.js
537+
interface ResponseError {
538+
error_code?: string,
539+
error?: string,
540+
}
541+
537542
class ResponseWrapper<T = any> {
538-
data: T;
543+
data: T extends void ? undefined | ResponseError : T & ResponseError;
539544
resp: IncomingMessage;
540545
constructor(options: ResponseWrapperOptions);
541546
ok(): boolean;

0 commit comments

Comments
 (0)