Resolve 'arguments' for rest args relative to direct parent.
This commit is contained in:
@@ -29,6 +29,7 @@ function remap(path, key, create) {
|
||||
if (!shouldShadow(path, shadowPath)) return;
|
||||
|
||||
let shadowFunction = path.node._shadowedFunctionLiteral;
|
||||
|
||||
let currentFunction;
|
||||
let passedShadowFunction = false;
|
||||
|
||||
@@ -56,6 +57,13 @@ function remap(path, key, create) {
|
||||
return false;
|
||||
});
|
||||
|
||||
if (shadowFunction && fnPath.isProgram() && !shadowFunction.isProgram()){
|
||||
// If the shadow wasn't found, take the closest function as a backup.
|
||||
// This is a bit of a hack, but it will allow the parameter transforms to work properly
|
||||
// without introducing yet another shadow-controlling flag.
|
||||
fnPath = path.findParent((p) => p.isProgram() || p.isFunction());
|
||||
}
|
||||
|
||||
// no point in realiasing if we're in this function
|
||||
if (fnPath === currentFunction) return;
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
async function s(x) {
|
||||
let t = async (y, a) => {
|
||||
let r = async (z, b) => {
|
||||
await z;
|
||||
return this.x;
|
||||
}
|
||||
await r();
|
||||
|
||||
return this.g(r);
|
||||
}
|
||||
|
||||
await t();
|
||||
return this.h(t);
|
||||
}
|
||||
async function s(x, ...args) {
|
||||
let t = async (y, a) => {
|
||||
let r = async (z, b, ...innerArgs) => {
|
||||
await z;
|
||||
console.log(this, innerArgs, arguments);
|
||||
return this.x;
|
||||
}
|
||||
await r();
|
||||
|
||||
console.log(this, args, arguments);
|
||||
return this.g(r);
|
||||
}
|
||||
|
||||
await t();
|
||||
return this.h(t);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
let s = (() => {
|
||||
var ref = babelHelpers.asyncToGenerator(function* (x) {
|
||||
var _this = this;
|
||||
var _this = this,
|
||||
_arguments = arguments;
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
let t = (() => {
|
||||
var ref = babelHelpers.asyncToGenerator(function* (y, a) {
|
||||
let r = (() => {
|
||||
var ref = babelHelpers.asyncToGenerator(function* (z, b) {
|
||||
for (var _len2 = arguments.length, innerArgs = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
||||
innerArgs[_key2 - 2] = arguments[_key2];
|
||||
}
|
||||
|
||||
yield z;
|
||||
console.log(_this, innerArgs, _arguments);
|
||||
return _this.x;
|
||||
});
|
||||
return function r(_x4, _x5) {
|
||||
@@ -15,6 +25,7 @@ let s = (() => {
|
||||
})();
|
||||
yield r();
|
||||
|
||||
console.log(_this, args, _arguments);
|
||||
return _this.g(r);
|
||||
});
|
||||
return function t(_x2, _x3) {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
{
|
||||
"plugins": ["external-helpers", "transform-async-to-generator"]
|
||||
"plugins": [
|
||||
"external-helpers",
|
||||
"transform-es2015-parameters",
|
||||
"transform-async-to-generator"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -213,7 +213,11 @@ export function inType() {
|
||||
* - _forceShadow - If truthy, this specific identifier will be bound in the closest
|
||||
* Function that is not flagged "shadow", or the Program.
|
||||
* - _shadowedFunctionLiteral - When set to a NodePath, this specific identifier will be bound
|
||||
* to this NodePath/Node or the Program.
|
||||
* to this NodePath/Node or the Program. If this path is not found relative to the
|
||||
* starting location path, the closest function will be used.
|
||||
*
|
||||
* Please Note, these flags are for private internal use only and should be avoided.
|
||||
* Only "shadow" is a public property that other transforms may manipulate.
|
||||
*/
|
||||
|
||||
export function inShadow(key?) {
|
||||
|
||||
Reference in New Issue
Block a user