* Handle arrow function processing via shared API rather than default plugin. * Fix a few small PR comments. * Preserve existing spec arrow 'this' rewrites, and support spec in subclass constructors.
23 lines
740 B
JavaScript
23 lines
740 B
JavaScript
// @flow
|
|
|
|
import { type NodePath } from "babel-traverse";
|
|
|
|
export default function () {
|
|
return {
|
|
visitor: {
|
|
ArrowFunctionExpression(path: NodePath<BabelNodeArrowFunctionExpression>, state: Object) {
|
|
// In some conversion cases, it may have already been converted to a function while this callback
|
|
// was queued up.
|
|
if (!path.isArrowFunctionExpression()) return;
|
|
|
|
path.arrowFunctionToExpression({
|
|
// While other utils may be fine inserting other arrows to make more transforms possible,
|
|
// the arrow transform itself absolutely cannot insert new arrow functions.
|
|
allowInsertArrow: false,
|
|
specCompliant: !!state.opts.spec,
|
|
});
|
|
},
|
|
},
|
|
};
|
|
}
|