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

Proposal: Information about change of injection token generation (introduced in v8) #2632

Open
1 of 5 tasks
Flusinerd opened this issue Feb 19, 2023 · 1 comment
Open
1 of 5 tasks

Comments

@Flusinerd
Copy link
Contributor

Flusinerd commented Feb 19, 2023

I'm submitting a...

  • Regression
  • Bug report
  • Feature request
  • Documentation issue or request (new chapter/page)
  • Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Currently there is no information on the the breaking change about injection token generation which changed in version 8.
Every few days there is a question related to this topic in the NestJS Discord why this and that no longer works:

Example:
My code no longer works:

My provider:

{
  provide: SomeProvider,
  useClass: SomeClass,
}

My service:

...
constructor(private readonly someProvider: SomeProvider)
...

The error is Error: Nest can't resolve dependencies of the .....

It comes down to people not knowing about the change that injection tokens are no longer the class names.

Expected behavior

Update the v8 migration guide to include a note about this change and an explanation why the old way worked and the new doesn't.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Better informed developers

Environment

For Tooling issues:

  • Node version: XX
  • Platform:

Others:

I know it was not ment for "consumers" to know about this and they should have used the @Inject decorator but juding by the amount of questions related to this it might not be common knowledge.

@Tony133
Copy link
Contributor

Tony133 commented Feb 20, 2023

You could add a warning, but I'm not sure if this is the best idea. 🤔
Because in the documentation if I'm not mistaken the use of string class names as injection tokens was never really documented.

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