diff --git a/src/classes/child-pool.ts b/src/classes/child-pool.ts index fdd53c5ab2..880d9fac37 100644 --- a/src/classes/child-pool.ts +++ b/src/classes/child-pool.ts @@ -1,12 +1,11 @@ -import childProcess, { ChildProcess } from 'child_process'; -import path from 'path'; +import { ChildProcess, fork } from 'child_process'; +import * as path from 'path'; import { forEach, values, flatten } from 'lodash'; -import getPort from 'get-port'; -import fs from 'fs'; +import * as getPort from 'get-port'; +import * as fs from 'fs'; import { promisify } from 'util'; const stat = promisify(fs.stat); -const fork = childProcess.fork; export interface ChildProcessExt extends ChildProcess { processFile?: string; diff --git a/src/classes/job.ts b/src/classes/job.ts index 3ea4450a63..f4951f7d78 100644 --- a/src/classes/job.ts +++ b/src/classes/job.ts @@ -1,4 +1,4 @@ -import IORedis from 'ioredis'; +import { Redis, Pipeline } from 'ioredis'; import { debuglog } from 'util'; import { RetryErrors } from '../enums'; import { BackoffOptions, JobsOptions, WorkerOptions } from '../interfaces'; @@ -92,7 +92,7 @@ export class Job { const multi = client.multi(); for (const job of jobInstances) { - job.addJob((multi as unknown)); + job.addJob((multi as unknown)); } const result = (await multi.exec()) as [null | Error, string][]; @@ -457,7 +457,7 @@ export class Job { ); } - private addJob(client: IORedis.Redis): string { + private addJob(client: Redis): string { const queue = this.queue; const jobData = this.asJSON(); @@ -465,7 +465,7 @@ export class Job { return Scripts.addJob(client, queue, jobData, this.opts, this.id); } - private saveAttempt(multi: IORedis.Pipeline, err: Error) { + private saveAttempt(multi: Pipeline, err: Error) { this.attemptsMade++; this.stacktrace = this.stacktrace || []; diff --git a/src/classes/redis-connection.ts b/src/classes/redis-connection.ts index 7021126be4..768fffcdf4 100644 --- a/src/classes/redis-connection.ts +++ b/src/classes/redis-connection.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import IORedis, { Redis } from 'ioredis'; +import * as IORedis from 'ioredis'; import * as semver from 'semver'; import { load } from '../commands'; import { ConnectionOptions, RedisOptions } from '../interfaces'; @@ -7,8 +7,8 @@ import { isRedisInstance } from '../utils'; export class RedisConnection extends EventEmitter { static minimumVersion = '5.0.0'; - private _client: Redis; - private initializing: Promise; + private _client: IORedis.Redis; + private initializing: Promise; private closing: boolean; constructor(private opts?: ConnectionOptions) { @@ -24,7 +24,7 @@ export class RedisConnection extends EventEmitter { ...opts, }; } else { - this._client = opts; + this._client = opts; } this.initializing = this.init(); @@ -60,7 +60,7 @@ export class RedisConnection extends EventEmitter { }); } - get client(): Promise { + get client(): Promise { return this.initializing; } diff --git a/src/classes/timer-manager.ts b/src/classes/timer-manager.ts index 44bde84a7f..5a38c8b057 100644 --- a/src/classes/timer-manager.ts +++ b/src/classes/timer-manager.ts @@ -1,4 +1,4 @@ -import uuid from 'uuid'; +import * as uuid from 'uuid'; /** * Keeps track on timers created with setTimeout to help clearTimeout diff --git a/src/classes/worker.ts b/src/classes/worker.ts index 9ab8be7ead..a97729c412 100644 --- a/src/classes/worker.ts +++ b/src/classes/worker.ts @@ -1,6 +1,6 @@ -import fs from 'fs'; +import * as fs from 'fs'; import { Redis } from 'ioredis'; -import path from 'path'; +import * as path from 'path'; import { Processor, WorkerOptions } from '../interfaces'; import { QueueBase, Repeat } from './'; import { ChildPool, pool } from './child-pool'; @@ -8,7 +8,7 @@ import { Job } from './job'; import { RedisConnection } from './redis-connection'; import sandbox from './sandbox'; import { Scripts } from './scripts'; -import uuid from 'uuid'; +import * as uuid from 'uuid'; import { TimerManager } from './timer-manager'; import { isRedisInstance } from '../utils'; diff --git a/src/commands/index.ts b/src/commands/index.ts index 53f9c81bd8..acd14e3a05 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -12,7 +12,7 @@ */ 'use strict'; -import IORedis from 'ioredis'; +import { Redis } from 'ioredis'; const path = require('path'); const util = require('util'); @@ -30,7 +30,7 @@ interface Command { }; } -export const load = async function(client: IORedis.Redis) { +export const load = async function(client: Redis) { const scripts = await loadScripts(__dirname); scripts.forEach((command: Command) => { diff --git a/src/interfaces/queue-options.ts b/src/interfaces/queue-options.ts index 8aef15c8dd..4dec999f18 100644 --- a/src/interfaces/queue-options.ts +++ b/src/interfaces/queue-options.ts @@ -1,6 +1,6 @@ import { JobsOptions } from '../interfaces'; -import IORedis from 'ioredis'; +import { Redis } from 'ioredis'; import { ConnectionOptions } from './redis-options'; export enum ClientType { @@ -10,7 +10,7 @@ export enum ClientType { export interface QueueBaseOptions { connection?: ConnectionOptions; - client?: IORedis.Redis; + client?: Redis; prefix?: string; // prefix for all queue keys. } diff --git a/src/interfaces/redis-options.ts b/src/interfaces/redis-options.ts index 52c23639f7..23d6c81cde 100644 --- a/src/interfaces/redis-options.ts +++ b/src/interfaces/redis-options.ts @@ -1,7 +1,7 @@ -import IORedis from 'ioredis'; +import { Redis, RedisOptions as BaseRedisOptions } from 'ioredis'; -export type RedisOptions = IORedis.RedisOptions & { +export type RedisOptions = BaseRedisOptions & { skipVersionCheck?: boolean; }; -export type ConnectionOptions = RedisOptions | IORedis.Redis; +export type ConnectionOptions = RedisOptions | Redis; diff --git a/src/test/test_bulk.ts b/src/test/test_bulk.ts index dcc6530285..11f63dbf7b 100644 --- a/src/test/test_bulk.ts +++ b/src/test/test_bulk.ts @@ -1,6 +1,6 @@ import { Queue, Worker, Job } from '../classes'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; import { removeAllQueueData } from '../utils'; diff --git a/src/test/test_clean.ts b/src/test/test_clean.ts index d3bd5a66cc..e07d47e6b4 100644 --- a/src/test/test_clean.ts +++ b/src/test/test_clean.ts @@ -1,7 +1,7 @@ import { Queue, QueueEvents, Worker } from '../classes'; import { delay, removeAllQueueData } from '@src/utils'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; diff --git a/src/test/test_compat.ts b/src/test/test_compat.ts index 862c6f9e21..dd58b8fb37 100644 --- a/src/test/test_compat.ts +++ b/src/test/test_compat.ts @@ -6,7 +6,7 @@ import { Job, Worker } from '@src/classes'; import { Queue3 } from '@src/classes/compat'; import { delay, removeAllQueueData } from '@src/utils'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { afterEach, beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; diff --git a/src/test/test_connection.ts b/src/test/test_connection.ts index 0836e8e011..f9bb4320e3 100644 --- a/src/test/test_connection.ts +++ b/src/test/test_connection.ts @@ -1,4 +1,4 @@ -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { Queue, QueueEvents, Job, Worker } from '@src/classes'; import { v4 } from 'uuid'; diff --git a/src/test/test_delay.ts b/src/test/test_delay.ts index 17254cfe60..3ef41746ad 100644 --- a/src/test/test_delay.ts +++ b/src/test/test_delay.ts @@ -1,7 +1,7 @@ import { Queue, Job } from '@src/classes'; import { describe, beforeEach, it } from 'mocha'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { v4 } from 'uuid'; import { Worker } from '@src/classes/worker'; import { QueueEvents } from '@src/classes/queue-events'; diff --git a/src/test/test_events.ts b/src/test/test_events.ts index 10bff3154f..fed6ccb4a8 100644 --- a/src/test/test_events.ts +++ b/src/test/test_events.ts @@ -2,7 +2,7 @@ import { Queue } from '@src/classes'; import { QueueEvents } from '@src/classes/queue-events'; import { Worker } from '@src/classes/worker'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; import { delay, removeAllQueueData } from '@src/utils'; diff --git a/src/test/test_getters.ts b/src/test/test_getters.ts index 82703ace26..dec93c091f 100644 --- a/src/test/test_getters.ts +++ b/src/test/test_getters.ts @@ -5,7 +5,7 @@ import { Queue, Job } from '@src/classes'; import { describe, beforeEach, it } from 'mocha'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { v4 } from 'uuid'; import { Worker } from '@src/classes/worker'; import { after } from 'lodash'; diff --git a/src/test/test_job.ts b/src/test/test_job.ts index 38b9f5971d..02eee0c752 100644 --- a/src/test/test_job.ts +++ b/src/test/test_job.ts @@ -7,7 +7,7 @@ import { Worker } from '@src/classes/worker'; import { JobsOptions } from '@src/interfaces'; import { delay, removeAllQueueData } from '@src/utils'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { afterEach, beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; diff --git a/src/test/test_pause.ts b/src/test/test_pause.ts index 655e675bc2..d70dfc29fe 100644 --- a/src/test/test_pause.ts +++ b/src/test/test_pause.ts @@ -2,7 +2,7 @@ import { Job, Queue } from '@src/classes'; import { QueueEvents, QueueScheduler } from '../classes'; import { Worker } from '@src/classes/worker'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; import { delay, removeAllQueueData } from '@src/utils'; diff --git a/src/test/test_queue.ts b/src/test/test_queue.ts index e8368a1e58..56a972e02b 100644 --- a/src/test/test_queue.ts +++ b/src/test/test_queue.ts @@ -2,7 +2,7 @@ import { Queue } from '@src/classes'; import { describe, beforeEach, it } from 'mocha'; import { expect, assert } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { v4 } from 'uuid'; import { Worker } from '@src/classes/worker'; import { after } from 'lodash'; diff --git a/src/test/test_rate_limiter.ts b/src/test/test_rate_limiter.ts index c42ff7ae79..87b7014044 100644 --- a/src/test/test_rate_limiter.ts +++ b/src/test/test_rate_limiter.ts @@ -3,7 +3,7 @@ import { QueueEvents } from '@src/classes/queue-events'; import { QueueScheduler } from '@src/classes/queue-scheduler'; import { Worker } from '@src/classes/worker'; import { assert, expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; diff --git a/src/test/test_repeat.ts b/src/test/test_repeat.ts index faa57cb165..71ebe3efbb 100644 --- a/src/test/test_repeat.ts +++ b/src/test/test_repeat.ts @@ -4,7 +4,7 @@ import { QueueScheduler } from '@src/classes/queue-scheduler'; import { Repeat } from '@src/classes/repeat'; import { Worker } from '@src/classes/worker'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; import { defaults } from 'lodash'; diff --git a/src/test/test_sandboxed_process.ts b/src/test/test_sandboxed_process.ts index 381837a292..59b3f1b594 100644 --- a/src/test/test_sandboxed_process.ts +++ b/src/test/test_sandboxed_process.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { Queue, QueueEvents, Worker, pool } from '@src/classes'; import { beforeEach } from 'mocha'; diff --git a/src/test/test_stalled_jobs.ts b/src/test/test_stalled_jobs.ts index 7cbeb31300..6f16d60e12 100644 --- a/src/test/test_stalled_jobs.ts +++ b/src/test/test_stalled_jobs.ts @@ -1,6 +1,6 @@ import { Queue, QueueScheduler, Worker, QueueEvents } from '@src/classes'; import { delay, removeAllQueueData } from '@src/utils'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { after } from 'lodash'; import { beforeEach, describe, it } from 'mocha'; import { v4 } from 'uuid'; diff --git a/src/test/test_worker.ts b/src/test/test_worker.ts index 942e9c633d..cb61f2a47f 100644 --- a/src/test/test_worker.ts +++ b/src/test/test_worker.ts @@ -1,7 +1,7 @@ import { Queue, QueueEvents, Job, Worker, QueueScheduler } from '@src/classes'; import { describe, beforeEach, it } from 'mocha'; import { expect } from 'chai'; -import IORedis from 'ioredis'; +import * as IORedis from 'ioredis'; import { v4 } from 'uuid'; import { delay, removeAllQueueData } from '@src/utils'; import { after, times, once } from 'lodash'; diff --git a/src/utils.ts b/src/utils.ts index 0b2e39fd5c..88bfda91ec 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import IORedis from 'ioredis'; +import { Redis } from 'ioredis'; export const errorObject: { [index: string]: any } = { value: null }; @@ -43,7 +43,7 @@ export function isRedisInstance(obj: any): boolean { } export async function removeAllQueueData( - client: IORedis.Redis, + client: Redis, queueName: string, prefix = 'bull', ) { diff --git a/tsconfig.json b/tsconfig.json index 189342c836..90fa0de4e8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,8 +11,8 @@ "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, + "esModuleInterop": false, + "allowSyntheticDefaultImports": false, "strictNullChecks": false, "baseUrl": ".", "paths": {