Merge pull request #24285 from DomiR/master

types/got: timeout can also be object, not just number
This commit is contained in:
Arthur Ozga
2018-03-15 12:20:07 -07:00
committed by GitHub
2 changed files with 20 additions and 2 deletions
+14
View File
@@ -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);
+6 -2
View File
@@ -98,7 +98,11 @@ declare namespace got {
json?: boolean;
}
type GotOptions<E extends string | null> = http.RequestOptions & {
interface TimoutRequestOptions extends http.RequestOptions {
timeout?: any;
}
interface GotOptions<E extends string | null> 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;