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

TS2322: Type 'BullMQAdapter' is not assignable to type 'BaseAdapter' (Wrong Types) #271

Closed
AlexZeDim opened this issue May 7, 2021 · 9 comments

Comments

@AlexZeDim
Copy link

AlexZeDim commented May 7, 2021

Hi!

I got almost the same issue, as it was mentioned a while ago in this report #253. Unless old things don't help me.

Node.js: 16.1

package.json

  "dependencies": {
    "@anchan828/nest-bullmq": "^0.5.20",
    "@nestjs/common": "^7.6.15",
    "@nestjs/core": "^7.6.15",
    "@nestjs/mongoose": "^7.2.4",
    "@nestjs/platform-express": "^7.6.15",
    "@nestjs/schedule": "^0.4.3",
    "@nestjs/swagger": "^4.8.0",
    "@types/cheerio": "^0.22.28",
    "bullmq": "^1.15.1",
    "rimraf": "^3.0.2",
  },
  "devDependencies": {
    "@nestjs/cli": "^7.6.0",
    "@nestjs/schematics": "^7.3.0",
    "@nestjs/testing": "^7.6.15",
    "@types/bull-board": "^0.6.0",
    "@types/config": "^0.0.38",
    "@types/cron": "^1.7.2",
    "@types/express": "^4.17.11",
    "@types/ioredis": "^4.26.1",
    "@types/jest": "^26.0.22",
    "@types/lodash": "^4.14.168",
    "@types/node": "^14.14.36",
    "bull-board": "^2.0.2",
    "ts-loader": "^8.0.18",
    "ts-node": "^9.1.1",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.2.3",
    "webpack": "^5.36.2"
  }

As you may see, I am using bull-board with nestjs. Here is a code image with error description:
image

Part of tsconfig.json responsible for imports:

    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,

And my IORedis tree

+-- @types/[email protected]
| `-- @types/[email protected]
|   `-- @types/[email protected] deduped
+-- @types/[email protected]
+-- [email protected]
| `-- @types/[email protected] deduped
`-- [email protected]
  `-- @types/[email protected] deduped

What have I done:

Of course, I have tried various things, like declaring variables with queues outside the createBullBoard part, downgrading (which helps), and so on.

But the funniest thing is, that actually bull-board is working fine, if I prefer to ignore errors manually via // @ts-ignore comments. So it's problem with interfaces, not with workability. But it is challengings to use bull-board in production.

@AlexZeDim
Copy link
Author

AlexZeDim commented May 7, 2021

After some investigation I have checked that the problem was created by the following string abstract getClient(): Promise<Redis.Redis>; in bull-board\dist\queueAdapters\base.d.ts file.

I removed .Redis and the result string:15 in method getClient() with: abstract getClient(): Promise<Redis>; gives me no error at last.

If so, a pull request #272 in opened. But I am not sure, that fixing my problem won't cause any others.

@felixmosh
Copy link
Owner

Thank you @AlexZeDim ... But seems that your fix failing on CI.

Try to remove @types/bull-board from your project since we ship the lib with built in types

@AlexZeDim
Copy link
Author

AlexZeDim commented May 8, 2021

Try to remove @types/bull-board from your project since we ship the lib with built-in types

I have tried with and without it. As for now, I am using 2.0.2 (latest) bull-board without @types/bull-board. Unfortunately, it doesn't help. As for the fix, I modify the compiled dist folder in my own fork (not this PR) that's why I don't receive any errors from TS.

For example <Redis> only:

image

And <Redis.Redis>

image

@felixmosh
Copy link
Owner

It is a confusion of types... not related to this lib.

can you try a fresh install? (removing node_modules & package.lock/yarn.lock)?

@AlexZeDim
Copy link
Author

Already done it too with yarn and npm with and without docker build. The problem related with BullMQAdapter and BaseAdapter class and their getClient().

@felixmosh
Copy link
Owner

Thank you for reporting this issue, I was able to reproduce the issue update updating types to latest 🙏🏼

@felixmosh
Copy link
Owner

Fix released at v2.0.3

@peon-root
Copy link

can we fix this for those on v1.*? It is still present in 1.7.2

@felixmosh
Copy link
Owner

Why do you not updating to v2?

The breaking changes are minor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants