Skip to content

Commit

Permalink
feat(TypeScript): harmonize definitions by using @octokit/types (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio authored and gr2m committed Nov 3, 2019
1 parent 138c5fb commit 56e5aa3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 41 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"homepage": "https://github.com/octokit/request-error.js#readme",
"dependencies": {
"@octokit/types": "^2.0.0",
"deprecation": "^2.0.0",
"once": "^1.4.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Deprecation } from "deprecation";
import once from "once";
const logOnce = once((deprecation: any) => console.warn(deprecation));

import { RequestOptions, ResponseHeaders, RequestErrorOptions } from "./types";
import { RequestOptions, ResponseHeaders } from "@octokit/types";
import { RequestErrorOptions } from "./types";

/**
* Error with extra properties to help with debugging
Expand Down
41 changes: 1 addition & 40 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,4 @@
/**
* Relative or absolute URL. Examples: `'/orgs/:org'`, `https://example.com/foo/bar`
*/
export type Url = string;

/**
* Request method
*/
export type Method = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";

export type RequestHeaders = {
/**
* Used for API previews and custom formats
*/
accept?: string;
/**
* Redacted authorization header
*/
authorization?: string;

"user-agent"?: string;

[header: string]: string | number | undefined;
};

export type ResponseHeaders = {
[header: string]: string;
};

export type EndpointRequestOptions = {
[option: string]: any;
};

export type RequestOptions = {
method: Method;
url: Url;
headers: RequestHeaders;
body?: any;
request?: EndpointRequestOptions;
};
import { RequestOptions, ResponseHeaders } from "@octokit/types";

export type RequestErrorOptions = {
headers: ResponseHeaders;
Expand Down

0 comments on commit 56e5aa3

Please sign in to comment.