Improve typings (#813)

The ApiResponse now accepts a generics that defaults to any, same for every API method that might need a body.
This commit is contained in:
Tomas Della Vedova
2019-04-10 11:40:25 +02:00
committed by delvedor
parent ef3126b361
commit 29beb44bf5
7 changed files with 644 additions and 229 deletions

4
lib/Transport.d.ts vendored
View File

@ -49,7 +49,7 @@ interface TransportOptions {
headers?: anyObject;
}
export interface RequestEvent {
export interface RequestEvent<T = any> {
body: any;
statusCode: number | null;
headers: anyObject | null;
@ -71,7 +71,7 @@ export interface RequestEvent {
// ApiResponse and RequestEvent are the same thing
// we are doing this for have more clear names
export interface ApiResponse extends RequestEvent {}
export interface ApiResponse<T = any> extends RequestEvent<T> {}
declare type anyObject = {
[key: string]: any;