Closed jjow closed 5 years ago
This is a fix for https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/175. @lencioni and I figured out that when removing newly unused identifiers in unsafe-wrap mode, we should just use the wrapTemplate instead of the unwrapTemplate.
unsafe-wrap
For example, const sharedPropType = PropTypes.number; would be transformed into:
const sharedPropType = PropTypes.number;
unwrapTemplate:
if (process.env.NODE_ENV !== "production") { const sharedPropType = PropTypes.number; // NOTE the scope issue here! }
wrapTemplate:
const sharedPropType = process.env.NODE_ENV !== "production" ? PropTypes.number : {};
Closes #175
This is a fix for https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/175. @lencioni and I figured out that when removing newly unused identifiers in
unsafe-wrap
mode, we should just use the wrapTemplate instead of the unwrapTemplate.For example,
const sharedPropType = PropTypes.number;
would be transformed into:unwrapTemplate:
wrapTemplate:
Closes #175