Typescript 5 @InjectModel
hxtree opened this issue · 2 comments
hxtree commented
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 commented
Notable references:
microsoft/TypeScript#52435
kamilmysliwiec commented
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));