diff --git a/src/babel/transformation/transformers/es6/classes.js b/src/babel/transformation/transformers/es6/classes.js index bde532ea03..db62df61e4 100644 --- a/src/babel/transformation/transformers/es6/classes.js +++ b/src/babel/transformation/transformers/es6/classes.js @@ -62,6 +62,18 @@ var verifyConstructorVisitor = traverse.explode({ } }, + FunctionDeclaration: { + enter() { + this.skip(); + } + }, + + FunctionExpression: { + enter() { + this.skip(); + } + }, + ThisExpression: { enter(node, parent, scope, state) { if (state.hasSuper && !state.hasBareSuper) { diff --git a/test/core/fixtures/transformation/misc/options.json b/test/core/fixtures/transformation/misc/options.json new file mode 100644 index 0000000000..7d6e6cda1c --- /dev/null +++ b/test/core/fixtures/transformation/misc/options.json @@ -0,0 +1,3 @@ +{ + "externalHelpers": true +} diff --git a/test/core/fixtures/transformation/misc/regression-1155/actual.js b/test/core/fixtures/transformation/misc/regression-1155/actual.js new file mode 100644 index 0000000000..f94a7f5899 --- /dev/null +++ b/test/core/fixtures/transformation/misc/regression-1155/actual.js @@ -0,0 +1,9 @@ +class Foo { + constructor (options) { + let parentOptions = {}; + parentOptions.init = function () { + this; + }; + super(parentOptions); + } +} diff --git a/test/core/fixtures/transformation/misc/regression-1155/expected.js b/test/core/fixtures/transformation/misc/regression-1155/expected.js new file mode 100644 index 0000000000..e9efbee824 --- /dev/null +++ b/test/core/fixtures/transformation/misc/regression-1155/expected.js @@ -0,0 +1,11 @@ +"use strict"; + +var Foo = function Foo(options) { + babelHelpers.classCallCheck(this, Foo); + + var parentOptions = {}; + parentOptions.init = function () { + this; + }; + babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this, parentOptions); +};