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

Missing required @injectable annotation - but I'm pretty sure I have... #524

Closed
atrauzzi opened this issue Apr 4, 2017 · 4 comments
Closed

Comments

@atrauzzi
Copy link

atrauzzi commented Apr 4, 2017

I have a class that helps with bindings that is getting called here: https://github.com/atrauzzi/protoculture/blob/master/demo/console.ts#L10-L17

The parent method it's using is here, which is where I call inversify: Which you can see here: https://github.com/atrauzzi/protoculture/blob/master/src/ServiceProvider.ts#L34-L37

All of this is orchestrated by this toplevel class, which does an import "reflect-metadata" here: https://github.com/atrauzzi/protoculture/blob/master/src/Suite/Base.ts#L1

But unfortunately, I still end up getting the following exception:

Error: Missing required @injectable annotation in: BoringConsoleDemoApp.
    at _createSubRequests (protoculture\node_modules\inversify\lib\planning\planner.js:107:19)
    at Object.plan (protoculture\node_modules\inversify\lib\planning\planner.js:126:5)
    at protoculture\node_modules\inversify\lib\container\container.js:228:37
    at Container._get (protoculture\node_modules\inversify\lib\container\container.js:221:44)
    at Container.getAll (protoculture\node_modules\inversify\lib\container\container.js:189:21)
    at ConsoleDemoSuite.BaseSuite.buildApps (protoculture\src\Suite\Base.ts:184:36)
    at ConsoleDemoSuite.<anonymous> (protoculture\src\Suite\Base.ts:140:18)
    at step (protoculture\src\Suite\Base.ts:31:23)
    at Object.next (protoculture\src\Suite\Base.ts:12:53)
    at fulfilled (protoculture\src\Suite\Base.ts:3:58)

Which is terrible, because I'm fairly certain I've done everything necessary to flag it as injectable. It's worth noting that if I do the annotation (which I'm trying to avoid), I get an error about applying the same annotation twice. A bit mysterious...

@remojansen
Copy link
Member

You need to decorate both the base and the derived class: BoringConsoleDemoApp extends BaseApp.
This means using injectable in BoringConsoleDemoApp and BaseApp. I'm not sure abut your makeInjectable function being invoked for BoringConsoleDemoApp and BaseApp?

The error:

Error: Missing required @Injectable annotation in: BoringConsoleDemoApp.

Looks bad too me, Inversify should be able to tell you that the base class is missing the annotation.

Will check out to see if there is something wrong with the error generation.

@atrauzzi
Copy link
Author

atrauzzi commented Apr 5, 2017

Yup, that worked!

https://github.com/atrauzzi/protoculture/blob/master/src/Suite/ProtocultureServiceProvider.ts#L10

I definitely agree, some mention of "hey, it's actually your abstract class that I don't know about" would be useful in this case.

@remojansen
Copy link
Member

I though that was the way the error worked. I must check it out. Will leave this issue open until I find out.

@remojansen
Copy link
Member

Closing this issue because I have created an issue that makes more clear how to reproduce the issue.

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