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

Wrong types in bull-board #253

Closed
exactmultiple3425 opened this issue Apr 19, 2021 · 21 comments
Closed

Wrong types in bull-board #253

exactmultiple3425 opened this issue Apr 19, 2021 · 21 comments
Labels
good first issue Good for newcomers

Comments

@exactmultiple3425
Copy link

When I try to compile the following code, this error occurs

const adapters = [new BullAdapter(this.chatroomQueue)];
setQueues(adapters);

Error

Argument of type 'BullAdapter[]' is not assignable to parameter of type 'readonly QueueAdapter[]'.
  Type 'BullAdapter' is not assignable to type 'QueueAdapter'.
    The types returned by 'getClient()' are incompatible between these types.

It is caused by BullAdapter.getClient() returns Promise<Queue['client']> while Queue extends EventEmitter and setQueues only accept QueueAdapter[] and QueueAdapter.getClient returns Promise<Redis.Redis> (Redis.Redis is a type of ioredis)

Please fix the types definition if available, thanks.

@felixmosh
Copy link
Owner

felixmosh commented Apr 19, 2021

Thank you for reporting this issue 🙏🏼

What version of TS are you using?

PR's are always welcome

@felixmosh felixmosh added the good first issue Good for newcomers label Apr 19, 2021
@felixmosh
Copy link
Owner

I've tested the code using ts entry, and it compiles fine.

  1. Clone this repo git clone [email protected]:felixmosh/bull-board.git
  2. Install dps yarn install
  3. Run example with yarn start:dev:server

It works as expected.

@exactmultiple3425
Copy link
Author

I'm using typescript 3.9.2
my package.json also includes [email protected]

@felixmosh
Copy link
Owner

I've just tested it with typescript 3.9.2, still works.

@exactmultiple3425
Copy link
Author

exactmultiple3425 commented Apr 21, 2021

image

is it possible because @types/bull is in dependencies instead of devDependencies?

@exactmultiple3425
Copy link
Author

I made the compilation working by the following steps

  1. Git clone bull-board project
  2. move all @types to devDependencies
  3. yarn && yarn build && yarn link

Move to my project

  1. Yarn remove bull-board
  2. yarn link bull-board
  3. yarn build

@felixmosh
Copy link
Owner

No, it should be in dependency, since types are part of the public api of the package (for TS users) and we consume them.

From the error looks like your ioredis types are not matched.

@felixmosh
Copy link
Owner

felixmosh commented Apr 21, 2021

I made the compilation working by the following steps

  1. Git clone bull-board project
  2. move all @types to devDependencies
  3. yarn && yarn build && yarn link

Move to my project

  1. Yarn remove bull-board
  2. yarn link bull-board
  3. yarn build

Yeah, but now you've lost a type safty as lib consumer.

I've made a clean new project that consumes bull-board using only bull, it works.

What version of @types/ioredis do you have?

@exactmultiple3425
Copy link
Author

I made the compilation working by the following steps

  1. Git clone bull-board project
  2. move all @types to devDependencies
  3. yarn && yarn build && yarn link

Move to my project

  1. Yarn remove bull-board
  2. yarn link bull-board
  3. yarn build

Yeah, but now you've lost a type safty as lib consumer.

I've made a clean new project that consumes bull-board using only bull, it works.

What version of @types/ioredis do you have?

4.16.2

@felixmosh
Copy link
Owner

felixmosh commented Apr 21, 2021

What version of bull?

I've released v1.5.3 with @types/ioredis as dependency, can you try it?

@exactmultiple3425
Copy link
Author

What version of bull?

[email protected]
[email protected]
[email protected]
@types/[email protected]

@felixmosh
Copy link
Owner

BTW, did you tried to clean install the project? (to remove node_modules & npm i)

@exactmultiple3425
Copy link
Author

BTW, did you tried to clean install the project? (to remove node_modules & npm i)

I did

@felixmosh
Copy link
Owner

Try v1.5.3 of bull-board.

Can you check the version of node_modules/@types/ioredis && node_modules/bull/node_modules/@types/ioredis?

@exactmultiple3425
Copy link
Author

Try v1.5.3 of bull-board.

Can you check the version of node_modules/@types/ioredis && node_modules/bull/node_modules/@types/ioredis?

node_modules/bull/node_modules/@types/ioredis: 4.14.9
node_modules/@types/ioredis: 4.16.2

tried 1.5.3, not working with another error message

error TS2345: Argument of type 'BullAdapter[]' is not assignable to parameter of type 'readonly QueueAdapter[]'.
  Type 'BullAdapter' is not assignable to type 'QueueAdapter'.
    The types returned by 'getClient()' are incompatible between these types.
      Type 'Promise<import("/Users/josephchong/work/projects/neard-js-server/node_modules/@types/bull/node_modules/@types/ioredis/index").Redis>' is not assignable to type 'Promise<import("/Users/josephchong/work/projects/neard-js-server/node_modules/bull-board/node_modules/@types/ioredis/index").Redis>'.
        Type 'Redis' is missing the following properties from type 'Redis': options, getrangeBuffer, lpushBuffer, lpos, and 21 more.

@felixmosh
Copy link
Owner

Weird... do you have "esModuleInterop": true, in your tsconfig.json?

@exactmultiple3425
Copy link
Author

yes, I did

@felixmosh
Copy link
Owner

felixmosh commented Apr 21, 2021

I don't understand why it install a different version of @types/ioredis for you...

Run npm ls @types/ioredis

I get

├─┬ [email protected]
│ ├─┬ @types/[email protected]
│ │ └── @types/[email protected] deduped
│ └── @types/[email protected]
└─┬ [email protected]
  └── @types/[email protected] deduped

Pls share your tree

@exactmultiple3425
Copy link
Author

├─┬ @types/[email protected]
│ └── @types/[email protected] 
├── @types/[email protected] 
├─┬ @types/[email protected]
│ └── @types/[email protected] 
├─┬ [email protected]
│ └── @types/[email protected] 
└─┬ [email protected]
  └── @types/[email protected] 

@felixmosh
Copy link
Owner

I've downgraded the bull version to 3.15.0, and I get the same install result.

├─┬ [email protected]
│ ├─┬ @types/[email protected]
│ │ └── @types/[email protected] deduped
│ └── @types/[email protected]
└─┬ [email protected]
  └── @types/[email protected] deduped

Pls remove any lock files and reinstall you deps.

@exactmultiple3425
Copy link
Author

I've downgraded the bull version to 3.15.0, and I get the same install result.

├─┬ [email protected]
│ ├─┬ @types/[email protected]
│ │ └── @types/[email protected] deduped
│ └── @types/[email protected]
└─┬ [email protected]
  └── @types/[email protected] deduped

Pls remove any lock files and reinstall you deps.

The issue is gone now and can be compiled now, thank you very much

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

No branches or pull requests

2 participants