Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modified imports to work when esModuleInterop is disabled #132

Merged
merged 5 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 4 additions & 5 deletions src/classes/child-pool.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/classes/job.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -92,7 +92,7 @@ export class Job<T = any, R = any> {
const multi = client.multi();

for (const job of jobInstances) {
job.addJob(<IORedis.Redis>(multi as unknown));
job.addJob(<Redis>(multi as unknown));
}

const result = (await multi.exec()) as [null | Error, string][];
Expand Down Expand Up @@ -454,15 +454,15 @@ export class Job<T = any, R = any> {
);
}

private addJob(client: IORedis.Redis): string {
private addJob(client: Redis): string {
const queue = this.queue;

const jobData = this.asJSON();

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 || [];

Expand Down
10 changes: 5 additions & 5 deletions src/classes/redis-connection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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';
import { isRedisInstance } from '../utils';

export class RedisConnection extends EventEmitter {
static minimumVersion = '5.0.0';
private _client: Redis;
private initializing: Promise<Redis>;
private _client: IORedis.Redis;
private initializing: Promise<IORedis.Redis>;
private closing: boolean;

constructor(private opts?: ConnectionOptions) {
Expand All @@ -24,7 +24,7 @@ export class RedisConnection extends EventEmitter {
...opts,
};
} else {
this._client = <Redis>opts;
this._client = <IORedis.Redis>opts;
}

this.initializing = this.init();
Expand Down Expand Up @@ -60,7 +60,7 @@ export class RedisConnection extends EventEmitter {
});
}

get client(): Promise<Redis> {
get client(): Promise<IORedis.Redis> {
return this.initializing;
}

Expand Down
2 changes: 1 addition & 1 deletion src/classes/timer-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from 'uuid';
import * as uuid from 'uuid';

/**
* Keeps track on timers created with setTimeout to help clearTimeout
Expand Down
6 changes: 3 additions & 3 deletions src/classes/worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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';
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';

Expand Down
4 changes: 2 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
'use strict';

import IORedis from 'ioredis';
import { Redis } from 'ioredis';

const path = require('path');
const util = require('util');
Expand All @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/queue-options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JobsOptions } from '../interfaces';

import IORedis from 'ioredis';
import { Redis } from 'ioredis';
import { ConnectionOptions } from './redis-options';

export enum ClientType {
Expand All @@ -10,7 +10,7 @@ export enum ClientType {

export interface QueueBaseOptions {
connection?: ConnectionOptions;
client?: IORedis.Redis;
client?: Redis;
prefix?: string; // prefix for all queue keys.
}

Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/redis-options.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/test/test_bulk.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_clean.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_connection.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_delay.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_rate_limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_repeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_sandboxed_process.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_stalled_jobs.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_worker.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import IORedis from 'ioredis';
import { Redis } from 'ioredis';

export const errorObject: { [index: string]: any } = { value: null };

Expand Down Expand Up @@ -43,7 +43,7 @@ export function isRedisInstance(obj: any): boolean {
}

export async function removeAllQueueData(
client: IORedis.Redis,
client: Redis,
queueName: string,
prefix = 'bull',
) {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": false,
"strictNullChecks": false,
"baseUrl": ".",
"paths": {
Expand Down