amd-to-es6
amd-to-es6 copied to clipboard
Nested ES classes with constructors not supported
Hi, the transformer fails when processing an AMD module which have nested ES classes defining constructors.
define(['exports', 'require'], function(exports, require) {
class MyClass {
constructor() {
this.foo = 'bar';
this._helper = new Helper();
}
}
class Helper {
constructor() {
this.name = 'Helper';
}
init() {
// THIS NESTED CLASS WILL FAIL
this._private = class Helper {
constructor() {
this.value = 123;
}
}
this._util = new Util();
}
}
function Util() {
this.name = 'Util';
this._private = class Helper {
constructor() {
this.value = 123;
}
}
}
exports.MyClass = MyClass;
});
This results in the error
SyntaxError: Line 16, column 19: Duplicate constructor method in class
at constructError (/home/user/node_modules/cherow/dist/umd/cherow.js:5625:21)
at report (/home/user/node_modules/cherow/dist/umd/cherow.js:5664:7)
at parseClassElement (/home/user/node_modules/cherow/dist/umd/cherow.js:4398:19)
This works fine if the "constructor" method isn't defined.