Closed stjepangolemac closed 8 years ago
Hi, thanks a lot for reporting this issue. I'm about to release inversify@2.0.1
which contains a fix for this issue.
However, getFunctionName
is only called when there is an issue (e.g. a missing annotation). At the moment you are not able to see the error message because it throws but after upgrading to 2.0.1 you will get some error. The error description should help you but feel free to ask any questions if you need additional help.
I just released inversify@2.0.1 please let me know if it solves your issue 😄
It solves that error but now I have another one (caused by my implementation). My logger class extends winston logger which doesn't have injectable decorator. How am I supposed to fix this?
Here is the error.
Error: Missing required @injectable annotation in: Anonymous function: function (options) {
events.EventEmitter.call(this);
this.configure(options);
}
And it seems to point to this function in the winston logger https://github.com/winstonjs/winston/blob/master/lib/winston/logger.js line 25
var Logger = exports.Logger = function (options) {
events.EventEmitter.call(this);
this.configure(options);
};
Hi @stjepangolemac we have a small guide about this issue in our wiki https://github.com/inversify/InversifyJS/blob/master/wiki/inheritance.md#what-can-i-do-when-my-base-class-is-provided-by-a-third-party-module hope it solves your issue
Yes, that helped me a lot. You are very responsive and helpful, keep up the good work!
Function getFunctionName throws when its called by baseClassDependencyCount which passes following function.
Expected Behavior
I don't know what should happen when it receives function with no name because I don't know what is that function there for.
Current Behavior
getFunctionName receives function with no name and throws. Here is the output. return v.name ? v.name : v.toString().match(/^function\s*([^\s(]+)/)[1]; TypeError: Cannot read property '1' of null
Possible Solution
I don't know if my implementation is causing this but if it's not, function should check does the name ([1] in the array) exist after the regexp is done and continue accordingly.
Context
I'm trying to resolve my Logger class that depends on Settings class.
Logger
Settings
Kernel
Your Environment
Stack trace
return v.name ? v.name : v.toString().match(/^function\s*([^\s(]+)/)[1]; ^
TypeError: Cannot read property '1' of null at Object.getFunctionName (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/utils/utils.js:5:70) at Planner._getTargets (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/planning/planner.js:132:39) at Planner._baseClassDepencencyCount (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/planning/planner.js:195:32) at Planner._getDependencies (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/planning/planner.js:184:45) at Planner.createPlan (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/planning/planner.js:23:37) at Kernel._createContext (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/kernel/kernel.js:220:23) at /home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/kernel/kernel.js:214:26 at Array.map (native) at Kernel._plan (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/kernel/kernel.js:213:33) at Kernel._planAndResolve (/home/stjepan/Development/houseremote2.1/node_modules/inversify/lib/kernel/kernel.js:173:29)