Minor: remove any
s from createTaskWithTimeout
This commit is contained in:
parent
812b1c5b21
commit
b0b4c04c52
1 changed files with 5 additions and 5 deletions
|
@ -1,10 +1,10 @@
|
|||
// tslint:disable no-default-export
|
||||
|
||||
export default function createTaskWithTimeout(
|
||||
task: () => Promise<any>,
|
||||
export default function createTaskWithTimeout<T>(
|
||||
task: () => Promise<T>,
|
||||
id: string,
|
||||
options: { timeout?: number } = {}
|
||||
) {
|
||||
): () => Promise<T> {
|
||||
const timeout = options.timeout || 1000 * 60 * 2; // two minutes
|
||||
|
||||
const errorForStack = new Error('for stack');
|
||||
|
@ -12,7 +12,7 @@ export default function createTaskWithTimeout(
|
|||
return async () =>
|
||||
new Promise((resolve, reject) => {
|
||||
let complete = false;
|
||||
let timer: any = setTimeout(() => {
|
||||
let timer: NodeJS.Timeout | null = setTimeout(() => {
|
||||
if (!complete) {
|
||||
const message = `${id ||
|
||||
''} task did not complete in time. Calling stack: ${
|
||||
|
@ -43,7 +43,7 @@ export default function createTaskWithTimeout(
|
|||
}
|
||||
};
|
||||
|
||||
const success = (result: any) => {
|
||||
const success = (result: T) => {
|
||||
clearTimer();
|
||||
complete = true;
|
||||
resolve(result);
|
||||
|
|
Loading…
Reference in a new issue