taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
6.21k stars 407 forks source link

Build error with Timeout and 'semver' missing declaration #411

Closed EmilsWebbod closed 3 years ago

EmilsWebbod commented 3 years ago

When running production build on my server I get these errors connected to the bullmq. Seems to be connected to the "lib": ["dom"] setting in tsconfig, that TS thinks its using the DOM version of setTimeout. Tried to remove the dom setting but didn't remove the errors.

The server is running react with SSR and that's probably causing the issues.

Could you fix the types to support both dom and Node.js? and fix a declaration file for semver?

node_modules/bullmq/src/classes/job.ts:366:9 - error TS2322: Type 'number' is not assignable to type 'Timeout'.

366         timeout = setTimeout(
            ~~~~~~~

node_modules/bullmq/src/classes/redis-connection.ts:3:25 - error TS7016: Could not find a declaration file for module 'semver'. 'C:/Lu
dens/e-learning/elearning-api/node_modules/bullmq/node_modules/semver/semver.js' implicitly has an 'any' type.
  Try `npm install @types/semver` if it exists or add a new declaration (.d.ts) file containing `declare module 'semver';`

3 import * as semver from 'semver';
                          ~~~~~~~~

node_modules/bullmq/src/classes/timer-manager.ts:26:7 - error TS7006: Parameter 'timeoutId' implicitly has an 'any' type.

26       timeoutId => {
         ~~~~~~~~~

node_modules/bullmq/src/classes/timer-manager.ts:40:7 - error TS2322: Type 'number' is not assignable to type 'Timeout'.

40       timer,
         ~~~~~

  node_modules/bullmq/src/classes/timer-manager.ts:12:7
    12       timer: NodeJS.Timeout;
             ~~~~~
    The expected type comes from property 'timer' which is declared here on type '{ name: string; timer: Timeout; }'
tsconfig
{
  "include": ["lib/**/*", "declarations/*.d.ts"],
  "exclude": ["node_modules", "test", "dist", ".circleci"],
  "compilerOptions": {
    "lib": ["dom", "es2019"],
    "module": "commonjs",
    "noImplicitAny": true,
    "target": "es6",
    "outDir": "dist",
    "rootDir": "lib",
    "baseUrl": ".",
    "sourceMap": true,
    "noUnusedLocals": false,
    "moduleResolution": "node",
    "removeComments": true,
    "typeRoots": ["node_modules/@types", "declarations"],
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "jsx": "react"
  }
}
EmilsWebbod commented 3 years ago

Ah, found the problem.

Had one of these added with auto import import { QueueOptions } from 'bullmq/src/interfaces/index'; Caused errors on build