Skip to content

Commit

Permalink
fix(typescript): improve default response type (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
orta authored and gr2m committed Jan 15, 2018
1 parent 37933b2 commit ac39fb5
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions scripts/templates/index.d.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
*/

declare namespace Github {
export interface AnyResponse {
/** This is the data you would see in https://developer.github.com/v3/ */
data: any
/** Request metadata */
meta:{
'x-ratelimit-limit': string,
'x-ratelimit-remaining': string,
'x-ratelimit-reset': string,
'x-github-request-id': string,
'x-github-media-type': string,
link: string,
'last-modified': string,
etag: string,
status: string
}
}

export type WellKnownHeader =
{{#requestHeaders}}
| {{{.}}}
Expand Down Expand Up @@ -105,22 +124,22 @@ declare class Github {
hasLastPage(link: Github.Link): string | undefined;
hasFirstPage(link: Github.Link): string | undefined;
getNextPage(link: Github.Link, callback?: Github.Callback): Promise<any>;
getNextPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<any>;
getNextPage(link: Github.Link, callback?: Github.Callback): Promise<Github.AnyResponse>;
getNextPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<Github.AnyResponse>;

getPreviousPage(link: Github.Link, callback?: Github.Callback): Promise<any>;
getPreviousPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<any>;
getPreviousPage(link: Github.Link, callback?: Github.Callback): Promise<Github.AnyResponse>;
getPreviousPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<Github.AnyResponse>;

getLastPage(link: Github.Link, callback?: Github.Callback): Promise<any>;
getLastPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<any>;
getLastPage(link: Github.Link, callback?: Github.Callback): Promise<Github.AnyResponse>;
getLastPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<Github.AnyResponse>;

getFirstPage(link: Github.Link, callback?: Github.Callback): Promise<any>;
getFirstPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<any>;
getFirstPage(link: Github.Link, callback?: Github.Callback): Promise<Github.AnyResponse>;
getFirstPage(link: Github.Link, headers?: {[header: string]: any}, callback?: Github.Callback): Promise<Github.AnyResponse>;

{{#namespaces}}
{{namespace}}: {
{{#methods}}
{{method}}({{#paramTypeName}}params: Github.{{.}}, {{/paramTypeName}}callback?: Github.Callback): Promise<any>;
{{method}}({{#paramTypeName}}params: Github.{{.}}, {{/paramTypeName}}callback?: Github.Callback): Promise<Github.AnyResponse>;
{{/methods}}
};
{{/namespaces}}
Expand Down

0 comments on commit ac39fb5

Please sign in to comment.