mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
[@types/got] Fix for extended got instance when options are used (#34804)
* Fix extended got instance requiring duplicate `json: true` * Use partials rather than base options
This commit is contained in:
committed by
Armando Aguirre
parent
621b0e6094
commit
548df2e56f
@@ -269,6 +269,8 @@ got.extend({ method: 'POST' }).extend({ headers: {} }).stream('/example');
|
||||
// $ExpectType Promise<any>
|
||||
got.extend({ json: true })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<any>
|
||||
got.extend({ json: true })('/example', { query: {} }).then(({ body }) => body);
|
||||
// $ExpectType Promise<any>
|
||||
got.extend({ baseUrl: 'https://localhost' }).extend({ json: true })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({})('/example').then(({ body }) => body);
|
||||
@@ -276,20 +278,28 @@ got.extend({})('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ form: true, encoding: null })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ form: true, encoding: null })('/example', { query: {} }).then(({ body }) => body);
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ form: true, encoding: null, body: {} })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ form: true, encoding: 'utf8' })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ form: true, encoding: 'utf8' })('/example', { query: {} }).then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ form: true, encoding: 'utf8', body: {} })('/example').then(({ body }) => body);
|
||||
// Body options:
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ encoding: null })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ encoding: null, body: '{}' })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<Buffer>
|
||||
got.extend({ encoding: null, body: '{}' })('/example', { query: {} }).then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ encoding: 'utf8' })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ encoding: 'utf8', body: '{}' })('/example').then(({ body }) => body);
|
||||
// $ExpectType Promise<string>
|
||||
got.extend({ encoding: 'utf8', body: '{}' })('/example', { query: {} }).then(({ body }) => body);
|
||||
|
||||
// Test retry options.
|
||||
got('http://todomvc.com', { retry: 2 });
|
||||
|
||||
4
types/got/index.d.ts
vendored
4
types/got/index.d.ts
vendored
@@ -90,12 +90,12 @@ declare namespace got {
|
||||
|
||||
interface GotJSONFn {
|
||||
(url: GotUrl): GotPromise<any>;
|
||||
(url: GotUrl, options: GotJSONOptions): GotPromise<any>;
|
||||
(url: GotUrl, options: Partial<GotJSONOptions>): GotPromise<any>;
|
||||
}
|
||||
|
||||
interface GotFormFn<T extends string | null> {
|
||||
(url: GotUrl): GotPromise<T extends null ? Buffer : string>;
|
||||
(url: GotUrl, options: GotFormOptions<T>): GotPromise<T extends null ? Buffer : string>;
|
||||
(url: GotUrl, options: Partial<GotFormOptions<T>>): GotPromise<T extends null ? Buffer : string>;
|
||||
}
|
||||
|
||||
interface GotBodyFn<T extends string | null> {
|
||||
|
||||
Reference in New Issue
Block a user