mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 06:40:35 +08:00
feat(got): add got timoutoptions
workaround for timeout fix test
This commit is contained in:
@@ -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);
|
||||
|
||||
8
types/got/index.d.ts
vendored
8
types/got/index.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user