Skip to content

Instantly share code, notes, and snippets.

@parshap
Last active October 4, 2016 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parshap/42af370d735f4167acf172c842353e3f to your computer and use it in GitHub Desktop.
Save parshap/42af370d735f4167acf172c842353e3f to your computer and use it in GitHub Desktop.
Babel 5 vs Babel 6 Difference

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).

export default (filters = {}, action = {}) => {
switch (action.type) {
case UPDATE_FILTERS:
let filters = {...filters}
filters[action.filter] = action.value
}
// Return the new state.
return filters
}
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;
};
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