为什么 Babel 解析箭头函数的 IIFE

Why Babel parses IIFE of arrow function

正如我从 ES2015 的语法中看到的,这个表达式是无效的:

() => { console.log("hello"); } ();

你至少需要加上括号:

(() => { console.log("hello"); }) ();

Chrome 在 Uncaught SyntaxError: Unexpected token (

的第一个样本上失败

但 Babel 对此表示满意。为什么?

But Babel is ok with that. Why?

因为 Babel 有问题 :-) 请参阅 https://phabricator.babeljs.io/T2118 and https://phabricator.babeljs.io/T2027。如果我理解正确的话,它是用 Babel 6 修复的——这是一个相当大的改变。