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[@targetName] error TS1239: Unable to resolve signature of parameter decorator when called as an expression #1556

Open
wangsyiiz opened this issue Feb 5, 2024 · 3 comments

Comments

@wangsyiiz
Copy link

Expected Behavior

There should not be any error occurred when @targetName be used at constructor

Current Behavior

constructor(@inject("IService") @targetName("queueService") ticketQueue: IService) { }

error TS1239: Unable to resolve signature of parameter decorator when called as an expression

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Version used: 6.0.2
  • Environment name and version: 16.20.2
  • Operating System and version: win11
  • Link to your project:

Stack trace

@wangsyiiz
Copy link
Author

ok, actually I found another decorator @named can be used in normally, but still in documentation it indicates to use @targetName, is that a wrong description?

@gustavohenke
Copy link

Both are documented, here's @named's: https://github.com/inversify/InversifyJS/blob/7619dd4395516fa53f435d08f30cead349901be8/wiki/named_bindings.md

The error comes from the signature of @targetName not properly matching the decorator signature anymore.
It's new on Typescript 5: microsoft/TypeScript#52435


That said, I don't understand the difference between @named and @targetName. @named seems slightly better supported, and @targetName's docs mention the use of namedConstraint, which doesn't work because it works on a different tag.

@gustavohenke
Copy link

Created #1561 to fix this.

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

No branches or pull requests

2 participants