From 7bb03173eeaedfbf4e6190c78d074c5f64919b75 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Thu, 25 Apr 2019 22:14:01 -0400 Subject: [PATCH] [@types/got] Support retries of "POST" method (#35000) * [@types/got] Support retries of "POST" method The current list of supported methods for RetryOptions omits the "POST" method. I believe this is because the list was taken from https://www.npmjs.com/package/got#retry however this is only the _default_ methods that are supported. [This issue](https://github.com/sindresorhus/got/issues/757) from the `got` GitHub repo indicates that it _is_ possible to specifically state that you would like to retry on POST as well. I have a use-case where I'd like to automatically retry failed POSTs but can't right now without overriding the typing. * Add @ryanwilsonperkin to authors list To allow dt-bot to ping me of changes to these interfaces and to help support additional typing changes. * Add test that "POST" is a supported method * Match order of other method lists Every other list of methods puts POST before PUT. Minor point, but may as well match convention. * fix: Remove duplicate POST --- types/got/got-tests.ts | 2 +- types/got/index.d.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index d3c0db19aa..9bb1b75d81 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -306,7 +306,7 @@ got('http://todomvc.com', { retry: 2 }); got('http://todomvc.com', { retry: { retries: 2, - methods: ['GET'], + methods: ['GET', 'POST'], statusCodes: [408, 504], maxRetryAfter: 1, errorCodes: ['ETIMEDOUT'] diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 6d070fcadd..20909101ca 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -5,6 +5,7 @@ // Konstantin Ikonnikov // Stijn Van Nieuwenhuyse // Matthew Bull +// Ryan Wilson-Perkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -251,7 +252,7 @@ declare namespace got { interface RetryOptions { retries?: number | RetryFunction; - methods?: Array<'GET' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE'>; + methods?: Array<'GET' | 'POST' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE'>; statusCodes?: Array<408 | 413 | 429 | 500 | 502 | 503 | 504>; maxRetryAfter?: number; /**