Babel 5 will incorrectly allow a let declration shadow an outter var declaration. See below and note the user of var _filters on line 7 by Babel 6 instead of var filters by Babel 5 (which shadows the var filters declared on line 2).
-
-
Save parshap/42af370d735f4167acf172c842353e3f to your computer and use it in GitHub Desktop.
Babel 5 vs Babel 6 Difference
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
| export default (filters = {}, action = {}) => { | |
| switch (action.type) { | |
| case UPDATE_FILTERS: | |
| let filters = {...filters} | |
| filters[action.filter] = action.value | |
| } | |
| // Return the new state. | |
| return filters | |
| } |
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
| exports['default'] = function () { | |
| var filters = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | |
| var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | |
| switch (action.type) { | |
| case _actions.UPDATE_FILTERS: | |
| var filters = _extends({}, filters); | |
| filters[action.filter] = action.value; | |
| } | |
| // Return the new state. | |
| return filters; | |
| }; |
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
| exports.default = function () { | |
| var filters = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | |
| var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | |
| switch (action.type) { | |
| case _actions.UPDATE_FILTERS: | |
| var _filters = _extends({}, _filters); | |
| _filters[action.filter] = action.value; | |
| } | |
| // Return the new state. | |
| return filters; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment