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

Typescript 5 @InjectModel #1717

Closed
2 of 4 tasks
hxtree opened this issue Mar 17, 2023 · 2 comments
Closed
2 of 4 tasks

Typescript 5 @InjectModel #1717

hxtree opened this issue Mar 17, 2023 · 2 comments
Labels

Comments

@hxtree
Copy link

hxtree commented Mar 17, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

After upgrade from Typescript 4.9 to 5 I get the following error:

    src/module/character-sheet/character-sheet.repository.ts:13: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'.

    13     @InjectModel(CharacterSheet.name)

Minimum reproduction code

https://github.com/hxtree/cats-cradle/tree/main/libraries/nestjs-modules

Steps to reproduce

Upgrade to latest tsc compiler

Was officially released March 16.
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/

Expected behavior

Ideally it would work the same on both 4.9 and 5

Package version

9.2.1

mongoose version

6.9.1

NestJS version

9.2.1

Node.js version

16

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@hxtree hxtree added the bug label Mar 17, 2023
@hxtree
Copy link
Author

hxtree commented Mar 17, 2023

Notable references:
microsoft/TypeScript#52435

nestjs/nest#10959

@kamilmysliwiec
Copy link
Member

InjectModel uses Inject under the hood so as long as you update to the latest version of @nestjs/common you should be fine:

export const InjectModel = (model: string, connectionName?: string) => Inject(getModelToken(model, connectionName));

@nestjs nestjs locked and limited conversation to collaborators Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants