Override toString in case this function is printed (#10949)
* Override toString in case this function is printed Related to https://stackoverflow.com/questions/59543968/unexpected-return-value-from-visitor-method * Don't override `toString` if `wrapper` is true Override `toString` immediately before returning a newFn, otherwise it will be overridden if wrapper is true https://github.com/babel/babel/pull/10949#discussion_r362302625 * prettier
This commit is contained in:
parent
26eb891870
commit
daaa2063bb
@ -227,6 +227,11 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper: ?Function) {
|
|||||||
newFn = wrapper(state.key, key, newFn);
|
newFn = wrapper(state.key, key, newFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`
|
||||||
|
if (newFn !== fn) {
|
||||||
|
newFn.toString = () => fn.toString();
|
||||||
|
}
|
||||||
|
|
||||||
return newFn;
|
return newFn;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user