diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index 7857bddbab..7048533295 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -52,6 +52,20 @@ got('todomvc.com', { encoding: 'utf8', hostname: 'todomvc' }).then(response => str = response.body); +got('todomvc.com', { + form: true, + body: [{}], + encoding: 'utf8', + hostname: 'todomvc', + timeout: 2000 +}).then(response => str = response.body); +got('todomvc.com', { + form: true, + body: [{}], + encoding: 'utf8', + hostname: 'todomvc', + timeout: {connect: 20, request: 20, socket: 20} +}).then(response => str = response.body); // following must lead to type checking error: got('todomvc.com', {form: true, body: ''}).then(response => str = response.body); got('todomvc.com', {encoding: null, hostname: 'todomvc'}).then(response => buf = response.body); diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 30a5b2c0be..5872b4f993 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -98,7 +98,11 @@ declare namespace got { json?: boolean; } - type GotOptions = http.RequestOptions & { + interface TimoutRequestOptions extends http.RequestOptions { + timeout?: any; + } + + interface GotOptions extends TimoutRequestOptions { encoding?: E; query?: string | object; timeout?: number | TimeoutOptions; @@ -106,7 +110,7 @@ declare namespace got { followRedirect?: boolean; decompress?: boolean; useElectronNet?: boolean; - }; + } interface TimeoutOptions { connect?: number;