From 743034fd59b5d66b1fb8ffb941da77143ae56f5d Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Thu, 15 Dec 2016 23:21:04 +0800 Subject: [PATCH 1/2] fix(babel): Loose mode breaks spread operator on Sets. Disable for now. --- lib/babel-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/babel-config.js b/lib/babel-config.js index 48235fb..7acc614 100644 --- a/lib/babel-config.js +++ b/lib/babel-config.js @@ -13,7 +13,7 @@ module.exports = function (env) { presets: [ [babelEnv, { targets: {browsers}, - loose: true + loose: false // Loose mode breaks spread operator on `Set`s }], react, stage2 From e8a186adbdd7392946c1c7aaaac08baa7e695c7b Mon Sep 17 00:00:00 2001 From: Trevor Gerhardt Date: Thu, 15 Dec 2016 23:40:33 +0800 Subject: [PATCH 2/2] test(babel): Added a test that fails in babel loose mode. --- lib/__tests__/babel.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/__tests__/babel.js diff --git a/lib/__tests__/babel.js b/lib/__tests__/babel.js new file mode 100644 index 0000000..0699ca5 --- /dev/null +++ b/lib/__tests__/babel.js @@ -0,0 +1,11 @@ +/* globals describe, expect, it */ + +describe('babel', () => { + /** As of 2016-12-15 this test fails in babel loose mode. https://github.com/babel/babel/issues/4916 */ + it('should iterate correctly over a set after using the spread operator', () => { + const originalArr = [1, 1, 2] + const set = new Set(originalArr) + const arr = [...set] + expect(arr.length).toBe(2) + }) +})