From ab5d87f8ef982c51722237d3b1761b7bb285bdb4 Mon Sep 17 00:00:00 2001 From: Matthew Bull Date: Tue, 29 Jan 2019 22:22:25 +0000 Subject: [PATCH] Add support for `got.extend` --- types/got/got-tests.ts | 4 ++++ types/got/index.d.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index afaac89ba4..6d011b3bc5 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -266,6 +266,10 @@ got('/examples/angularjs', { baseUrl: 'http://todomvc.com' }); got('http://todomvc.com', { headers: { foo: 'bar'} }); got('http://todomvc.com', { cookieJar: new tough.CookieJar() }); +// Test extension +got.extend({ method: 'POST' })('/example'); +got.extend({ method: 'POST' }).extend({ headers: {} }).stream('/example'); + // Test retry options. got('http://todomvc.com', { retry: 2 }); got('http://todomvc.com', { diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 0c847d6489..42c7442f88 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -4,6 +4,7 @@ // Linus Unnebäck // Konstantin Ikonnikov // Stijn Van Nieuwenhuyse +// Matthew Bull // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -72,6 +73,7 @@ declare const got: got.GotFn & Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotFn> & { stream: got.GotStreamFn & Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotStreamFn>; + extend: (options: got.GotJSONOptions | got.GotFormOptions | got.GotFormOptions | got.GotBodyOptions | got.GotBodyOptions) => typeof got; RequestError: typeof RequestError; ReadError: typeof ReadError; ParseError: typeof ParseError;