nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.73k stars 7.63k forks source link

Cryptic Error message when exported Component is not listed in Components collection #479

Closed mcMickJuice closed 6 years ago

mcMickJuice commented 6 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ / ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

If I omit an exported component from the components collection of a module but include it in the exports collection, I get a cryptic error when importing it into a component into a separate module.

Nest can't resolve dependencies of the OtherController (?). Please verify whether [0] argument
 is available in the current context.

Expected behavior

The error on boot should say something along the lines of "you have included a Component in the 'exports' collection but did not register it in the 'components' collection. This will cause DI to break. Please list all exported components in the 'components' AND 'exports' collection`

Minimal reproduction of the problem with instructions

https://github.com/mcMickJuice/typescript-starter

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

Better error messaging and less time wasted around incorrect component registration

Environment

    "@nestjs/common": "^4.5.9",
    "@nestjs/core": "^4.5.10",
    "@nestjs/microservices": "^4.5.8",
    "@nestjs/testing": "^4.5.5",
    "@nestjs/websockets": "^4.5.8",
kamilmysliwiec commented 6 years ago

Thanks for reporting @mcMickJuice !

kamilmysliwiec commented 6 years ago

Added in v4.6.6 🙂

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.