Closed orzarchi closed 9 years ago
I'm have never used inversify with harmony mode before, I was able to reproduce the issue and I'm trying to find a way to fix it. Will give you more details soon.
@orzarchi I have done a release (v.1.0.2) which resolves your issue:
Error: Could not resolve service class
However there is another issue that needs to be fixed in order to support ES6 native classes:
TypeError: Class constructors cannot be invoked without 'new'
I will fix it as soon as someone answers this SO question:
http://stackoverflow.com/questions/33193310/constr-applythis-args-in-es6-classes
Thanks for using inversify!
Hi @orzarchi I'm happy to let you know that if you download the version v1.0.3 from npm you should be able to use ES6 classes with --harmony
mode in node 4.0:
"use strict";
var inversify = require("inversify");
class A {
constructor(){
this.something = "A is doing something!";
}
doSomething(){
console.log(this.something);
}
}
class B {
constructor(a) {
this._a = a;
}
useA() {
this._a.doSomething();
}
}
var kernel = new inversify.Kernel();
kernel.bind(new inversify.TypeBinding('a', A));
kernel.bind(new inversify.TypeBinding('b', B));
var b = kernel.resolve('b');
b.useA();
I was able to run the file above using:
node index.js --harmony
Please let me know if you experience more issues.
Hi, thanks for adding this feature!
After poking around in your code, I think I have something that can help: I've found an npm module called node-introspect that seems to offer almost all the functionality needed to resolve argument names in functions and constructors.
I've made a pull request with some fixes ( https://github.com/kilianc/node-introspect/pull/4). Currently me and the author are working out the kinks. Since it seems like your argument resolve code is pretty similar, maybe we can all join forces, and you can reuse this code for Inversify?
On Sun, Oct 18, 2015 at 11:37 PM, Remo H. Jansen notifications@github.com wrote:
Hi @orzarchi https://github.com/orzarchi I'm happy to let you know that if you download the version v1.0.3 from npm you should be able to use ES6 classes with --harmony mode in node 4.0:
"use strict";
var inversify = require("inversify");
class A { constructor(){ this.something = "A is doing something!"; } doSomething(){ console.log(this.something); } }
class B { constructor(a) { this._a = a; } useA() { this._a.doSomething(); } }
var kernel = new inversify.Kernel(); kernel.bind(new inversify.TypeBinding('a', A)); kernel.bind(new inversify.TypeBinding('b', B));
var b = kernel.resolve('b'); b.useA();
I was able to run the file above using:
node index.js --harmony
Please let me know if you experience more issues.
— Reply to this email directly or view it on GitHub https://github.com/inversify/InversifyJS/issues/23#issuecomment-149045123 .
Using node 4.0 and native ES6 classes:
results in Error: Could not resolve service class