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

Decorator InjectQueue has error with TS 5.X #1639

Closed
2 of 4 tasks
andreyddk opened this issue Mar 24, 2023 · 1 comment
Closed
2 of 4 tasks

Decorator InjectQueue has error with TS 5.X #1639

andreyddk opened this issue Mar 24, 2023 · 1 comment
Labels
bug Something isn't working needs triage

Comments

@andreyddk
Copy link

andreyddk commented Mar 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

typescript 5.0.2
@nestjs/bull - latest

If add decorator InjectQueue in constructor then you see error.

Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'.

I guess the problem in returning type of decorator (ParameterDecorator), because another decorator no have same error (Inject)

Minimum reproduction code

https://github.com/andreyddk/nestjs-bull-inject-queue-decorator-failure

Steps to reproduce

npm i
npm run watch

Expected behavior

src/playground/playground.service.ts(10,6): error TS1239: Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'.

Package version

0.6.3

Bull version

4.10.4

NestJS version

9.3.12

Node.js version

18 lts

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

error TS1239: Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'undefined' is not assignable to parameter of type 'string | symbol'.

93     @InjectQueue('TEST_QUEUE')

Solution could be removing returning type ParameterDecorator or make the same type of nestjs Inject.
Example:

const InjectQueueV2 = (
  name?: string
): ((
  target: object,
  key: string | symbol | undefined,
  index?: number | undefined
) => void) => Inject(getQueueToken(name));

or

const InjectQueueV2 = (name?: string) => Inject(getQueueToken(name));

@andreyddk andreyddk added bug Something isn't working needs triage labels Mar 24, 2023
@kamilmysliwiec
Copy link
Member

InjectQueue uses Inject under the hood:

image

which was already updated to support TS 5.0. Update to the latest version of @nestjs/common and the error will be gone

@nestjs nestjs locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants