Last active
June 15, 2019 20:37
-
-
Save developit/1586a8896ba21fa87cde65714ee8c157 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** Converts destructured parameters with default values to non-shorthand syntax, fixing Edge 16 & 17. */ | |
module.exports = (babel, options = {}) => { | |
const { types: t } = babel; | |
const isArrowParent = p => p.parentKey=='params' && p.parentPath && p.parentPath.isArrowFunctionExpression(); | |
return { | |
name: "transform-edge-default-parameters", | |
visitor: { | |
AssignmentPattern(path) { | |
const arrowArgParent = path.find(isArrowParent); | |
if (arrowArgParent && path.parent.shorthand) { | |
path.parent.shorthand = false; | |
} | |
} | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment