Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion types/retry-as-promised/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import Promise = require('bluebird');

declare namespace retryAsPromised {
type MatchOption = string | RegExp | Error;
type MatchOption =
| string
| RegExp
| Error
// tslint:disable-next-line ban-types
| Function;
interface Options {
$current?: number | undefined;
max?: number | undefined;
Expand Down
15 changes: 12 additions & 3 deletions types/retry-as-promised/retry-as-promised-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import retry = require('retry-as-promised');
interface Product {
name: string;
}
declare abstract class BaseError extends Error {
constructor(message?: string);
}
declare class TestError extends BaseError {
/** The specific error which triggered this one */
parent: Error;
original: Error;
constructor(parent: Error);
}

const log = (...args: any[]): void => {};

Expand All @@ -12,7 +21,7 @@ retry(() => Promise.reject(new Error('No matching values')), {});
retry(() => Promise.resolve(), {
max: 100,
timeout: 60000,
match: ['Error matching values', new Error('No matching values'), new RegExp(/Deadlock/, 'i')],
match: ['Error matching values', new Error('No matching values'), new RegExp(/Deadlock/, 'i'), () => {}, TestError],
backoffBase: 100,
backoffExponent: 1.1,
name: 'Source',
Expand All @@ -21,7 +30,7 @@ retry(() => Promise.resolve(), {
log(options.name);
log('iteration', options.$current);
}
}
},
});
retry<Product>(() => Promise.resolve({ name: 'test' }) , {});
retry<Product>(() => Promise.resolve({ name: 'test' }), {});
retry<Product>(() => Promise.reject(new Error('No matching product')), {});