Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support transforming params of arrow functions in class fields (#13941)
- Loading branch information
1 parent
a6a5269
commit 43f9899
Showing
17 changed files
with
168 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...l-plugin-transform-parameters/test/fixtures/assumption-noNewArrows-false/default/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let f = (x = 0) => x + 1; |
7 changes: 7 additions & 0 deletions
7
...-plugin-transform-parameters/test/fixtures/assumption-noNewArrows-false/default/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var _this = this; | ||
|
||
let f = function f() { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
babelHelpers.newArrowCheck(this, _this); | ||
return x + 1; | ||
}.bind(this); |
6 changes: 6 additions & 0 deletions
6
...babel-plugin-transform-parameters/test/fixtures/assumption-noNewArrows-false/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": ["transform-parameters"], | ||
"assumptions": { | ||
"noNewArrows": false | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939-complex/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class A extends B { | ||
handle = ((x = 0) => { | ||
console.log(x, this, new.target, super.y); | ||
})(() => { | ||
let y = 0; | ||
return (x = y) => x + this; | ||
})((x = 1) => {})(this); | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/babel-plugin-transform-parameters/test/fixtures/regression/13939-complex/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939-complex/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class A extends B { | ||
handle = (() => { | ||
var _newtarget = new.target, | ||
_superprop_getY = () => super.y, | ||
_this = this; | ||
|
||
return function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
console.log(x, _this, _newtarget, _superprop_getY()); | ||
}; | ||
})()(() => { | ||
var _this2 = this; | ||
|
||
let y = 0; | ||
return function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : y; | ||
return x + _this2; | ||
}; | ||
})((() => function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
})())(this); | ||
} |
8 changes: 8 additions & 0 deletions
8
...babel-plugin-transform-parameters/test/fixtures/regression/13939-private-complex/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class A extends B { | ||
#handle = ((x = 0) => { | ||
console.log(x, this, new.target, super.y); | ||
})(() => { | ||
let y = 0; | ||
return (x = y) => x + this; | ||
})((x = 1) => {})(this); | ||
} |
5 changes: 5 additions & 0 deletions
5
...l-plugin-transform-parameters/test/fixtures/regression/13939-private-complex/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
...abel-plugin-transform-parameters/test/fixtures/regression/13939-private-complex/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class A extends B { | ||
#handle = (() => { | ||
var _newtarget = new.target, | ||
_superprop_getY = () => super.y, | ||
_this = this; | ||
|
||
return function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
console.log(x, _this, _newtarget, _superprop_getY()); | ||
}; | ||
})()(() => { | ||
var _this2 = this; | ||
|
||
let y = 0; | ||
return function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : y; | ||
return x + _this2; | ||
}; | ||
})((() => function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
})())(this); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939-private/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class A { | ||
#handle = (x = 0) => { | ||
console.log(x); | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/babel-plugin-transform-parameters/test/fixtures/regression/13939-private/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939-private/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class A { | ||
#handle = (() => function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
console.log(x); | ||
})(); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class A { | ||
handle = (x = 0) => { | ||
console.log(x); | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin-transform-parameters/test/fixtures/regression/13939/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class A { | ||
handle = (() => function () { | ||
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
console.log(x); | ||
})(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters