Skip to content

Commit

Permalink
Add default body type to Common interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed May 22, 2019
1 parent 7be8a22 commit 4d8e65e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type CommonBodyConstructor<T, U extends T> = {
/**
* Abstract body shared between node.js and browsers.
*/
export interface CommonBody<T> {
export interface CommonBody<T = unknown> {
$rawBody: T | null | undefined; // Use `undefined` as a mark of "used".
headers: Headers;
readonly bodyUsed: boolean;
Expand All @@ -51,10 +51,10 @@ export interface CommonRequestOptions<T> {
/**
* Request implementation standard.
*/
export interface CommonRequest<T> extends CommonBody<T> {
export interface CommonRequest<T = unknown> extends CommonBody<T> {
url: string
method: string
signal: Signal
headers: Headers
trailer: Promise<Headers>
}

Expand All @@ -71,9 +71,8 @@ export interface CommonResponseOptions {
/**
* Response implementation standard.
*/
export interface CommonResponse<T> extends CommonBody<T> {
export interface CommonResponse<T = unknown> extends CommonBody<T> {
status: number
statusText: string
headers: Headers
trailer: Promise<Headers>
}
5 changes: 3 additions & 2 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
EmptyBody,
CommonRequestOptions,
CommonResponseOptions,
CommonRequest
CommonRequest,
CommonResponse
} from "./common";

export type RawBody = Readable | Buffer | string;
Expand Down Expand Up @@ -217,7 +218,7 @@ export class Request extends Body implements CommonRequest<RawBody> {
/**
* Node.js `Response` implementation.
*/
export class Response extends Body {
export class Response extends Body implements CommonResponse<RawBody> {
status: number;
statusText: string;
trailer: Promise<Headers>;
Expand Down

0 comments on commit 4d8e65e

Please sign in to comment.