add illegal top level this transformer - fixes #562
This commit is contained in:
@@ -1 +1,3 @@
|
||||
var t = x => this.x + x;
|
||||
function b() {
|
||||
var t = x => this.x + x;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _this = this;
|
||||
var t = function (x) {
|
||||
return _this.x + x;
|
||||
};
|
||||
function b() {
|
||||
var _this = this;
|
||||
var t = function (x) {
|
||||
return _this.x + x;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
for (var [ name, before, after ] of this.test.expectation.registers) {
|
||||
for (var [ name, before, after ] of test.expectation.registers) {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var _slicedToArray = function (arr, i) {
|
||||
}
|
||||
};
|
||||
|
||||
for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var _step$value = _slicedToArray(_step.value, 3);
|
||||
|
||||
var name = _step$value[0];
|
||||
|
||||
@@ -1 +1 @@
|
||||
[this.foo, this.bar] = [1, 2];
|
||||
[foo.foo, foo.bar] = [1, 2];
|
||||
|
||||
@@ -20,5 +20,5 @@ var _ref = [1, 2];
|
||||
|
||||
var _ref2 = _slicedToArray(_ref, 2);
|
||||
|
||||
this.foo = _ref2[0];
|
||||
this.bar = _ref2[1];
|
||||
foo.foo = _ref2[0];
|
||||
foo.bar = _ref2[1];
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
var obj = {
|
||||
["x" + this.foo]: "heh"
|
||||
["x" + foo.bar]: "heh"
|
||||
};
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _this = this;
|
||||
var obj = (function () {
|
||||
var _obj = {};
|
||||
|
||||
_obj["x" + _this.foo] = "heh";
|
||||
_obj["x" + foo.foo] = "heh";
|
||||
return _obj;
|
||||
})();
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
var obj = {
|
||||
["x" + this.foo]: "heh"
|
||||
["x" + foo.bar]: "heh"
|
||||
};
|
||||
|
||||
@@ -9,4 +9,4 @@ var _defineProperty = function (obj, key, value) {
|
||||
});
|
||||
};
|
||||
|
||||
var obj = _defineProperty({}, "x" + this.foo, "heh");
|
||||
var obj = _defineProperty({}, "x" + foo.bar, "heh");
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<Component
|
||||
{...this.props}
|
||||
{...props}
|
||||
sound="moo" />
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
React.createElement(Component, React.__spread({}, this.props, {
|
||||
React.createElement(Component, React.__spread({}, props, {
|
||||
sound: "moo" }));
|
||||
|
||||
@@ -3,11 +3,11 @@ var x = <div>
|
||||
</div>;
|
||||
|
||||
var x = <div>
|
||||
{this.props.children}
|
||||
{props.children}
|
||||
</div>;
|
||||
|
||||
var x = <Composite>
|
||||
{this.props.children}
|
||||
{props.children}
|
||||
</Composite>;
|
||||
|
||||
var x = <Composite>
|
||||
|
||||
@@ -7,13 +7,13 @@ var x = React.createElement(
|
||||
var x = React.createElement(
|
||||
"div",
|
||||
null,
|
||||
this.props.children
|
||||
props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(
|
||||
Composite,
|
||||
null,
|
||||
this.props.children
|
||||
props.children
|
||||
);
|
||||
|
||||
var x = React.createElement(
|
||||
|
||||
1
test/fixtures/transformation/spec-illegal-top-level-this/arrow-function/actual.js
vendored
Normal file
1
test/fixtures/transformation/spec-illegal-top-level-this/arrow-function/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var foo = () => this;
|
||||
3
test/fixtures/transformation/spec-illegal-top-level-this/options.json
vendored
Normal file
3
test/fixtures/transformation/spec-illegal-top-level-this/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Top level `this` is not allowed"
|
||||
}
|
||||
1
test/fixtures/transformation/spec-illegal-top-level-this/root-call/actual.js
vendored
Normal file
1
test/fixtures/transformation/spec-illegal-top-level-this/root-call/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
this.foo();
|
||||
1
test/fixtures/transformation/spec-illegal-top-level-this/root-declaration/actual.js
vendored
Normal file
1
test/fixtures/transformation/spec-illegal-top-level-this/root-declaration/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var self = this;
|
||||
1
test/fixtures/transformation/spec-illegal-top-level-this/root-reference/actual.js
vendored
Normal file
1
test/fixtures/transformation/spec-illegal-top-level-this/root-reference/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
this;
|
||||
Reference in New Issue
Block a user