[@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
This commit is contained in:
Ryan Wilson-Perkin
2019-04-25 22:14:01 -04:00
committed by Pranav Senthilnathan
parent 8445dd431b
commit 7bb03173ee
2 changed files with 3 additions and 2 deletions

View File

@@ -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']

View File

@@ -5,6 +5,7 @@
// Konstantin Ikonnikov <https://github.com/ikokostya>
// Stijn Van Nieuwenhuyse <https://github.com/stijnvn>
// Matthew Bull <https://github.com/wingsbob>
// Ryan Wilson-Perkin <https://github.com/ryanwilsonperkin>
// 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;
/**