Repository navigation
Tighter parameter decorator checking with --experimentalDecorators #52435
Description
Activity
- addedBugA bug in TypeScriptA bug in TypeScript
on Jan 26, 2023 DanielRosenwasser commented
on Jan 26, 2023 MemberAuthorMore actionsWas this...possibly always a bug with
--experimentalDecorators?- changed the title
[-]Decorator call resolution regression with `--experimentalDecorators`[/-][+]Decorator call regression with `--experimentalDecorators`[/+]on Jan 26, 2023 - addedBreaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeand removedBugA bug in TypeScriptA bug in TypeScript
on Jan 26, 2023 DanielRosenwasser commented
on Jan 26, 2023 MemberAuthorMore actionsYes, it seems this was a bug in type-checking parameter decorators on constructors under
--experimentalDecoratorswith TypeScript 4.9 and prior.In #50820, we fixed up the way we type-checked decorators. This catches some issues, like decorators which expect a defined
key; however, parameter decorators in constructors don't get passed a key. As a result, libraries with dependency injection decorator functions like inversify (pre-6.0), NestJS, and others (often namedinject,Inject, andInjectRepository) might need to be corrected to accept anundefinedkey (or to have an overload which accepts anundefinedkey).- changed the title
[-]Decorator call regression with `--experimentalDecorators`[/-][+]Tighter parameter decorator checking with `--experimentalDecorators`[/+]on Jan 26, 2023 - addedWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
on Jan 26, 2023 inversify's@injectworks fine starting in[email protected].@nestjs/common's@injectneeds to be updated, however.Is tsyringe affected?
Reacted by Jeffrey Wen, Enzo.C and Japheth KiptooDanielRosenwasser commented
on Jan 27, 2023 MemberAuthorMore actionsDanielRosenwasser commented
on Jan 27, 2023 MemberAuthorMore actionsI filed an issue at NestJS over at #52435. I'm not sure how active TSyringe is at the moment.
typescript-bot commented
on Jan 29, 2023 ContributorMore actionsThis issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
I was able to solve this problem by adding these parameters to the
tsconfig.jsonfile:I used
inversify: 6.0.1versionNOTE: when I inserted it at the end of the file it didn't work, only when I put it at the beginning
{ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowJs": true, } }I hope I can help 😄
- locked as resolved and limited conversation to collaborators
on Oct 22, 2025
Previously: no error
In
main/5.0: