Babel v7.0.0-alpha.15 Release Notes

Release Date: 2017-07-11 // almost 7 years ago
  • This is a Stage 0 TC39 Proposal (subject to change/removal and your feedback!)

    const obj = {
      foo: {
        bar: {
          baz: 42,
        },
      },
    };
    
    const baz = obj?.foo?.bar?.baz; // 42
    
    const safe = obj?.qux?.baz; // undefined
    
    // Optional chaining and normal chaining can be intermixed
    obj?.foo.bar?.baz; // Only access `foo` if `obj` exists, and `baz` if
                       // `bar` exists
    
    function Foo() {
      console.log(new.target);
    }
    
    Foo(); // => undefined
    new Foo(); // => Foo
    
    • πŸ‘ better for of optimization (if inferred array)
    // these kinds of scenarios will compile to a regular for loop
    const x = [];
    for (const y of x) {}
    const arr = Object.entries(x);
    for (const y of arr) {}
    
    • loose mode for classes is a lot looser

    Input

    class A {}
    

    Output (loose)

    let A = function A() {}; // loose
    

    Output (normal)

    function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
    
    var A = function A() {
      _classCallCheck(this, A);
    };
    

    :boom: Breaking Change

    • babel-*
      • #5824 Hardcode to double quotes, indent to 2 spaces. (@hzoo)

    This is just the babel-generator output, not a big deal.

    :rocket: New Feature

    • babel-traverse
    • πŸ”Œ babel-plugin-transform-new-target
    • πŸ”Œ babel-core, babel-generator, babel-plugin-syntax-optional-chaining, babel-plugin-transform-optional-chaining, babel-preset-stage-1, babel-template, babel-traverse, babel-types
    • πŸ”Œ babel-core, babel-plugin-transform-es2015-for-of
      • #4747 test for for-of optimization on arrays and add it for array type anno…. (@hzoo)
    • πŸ”Œ babel-helpers, babel-plugin-transform-es2015-classes, babel-plugin-transform-flow-comments, babel-plugin-transform-flow-strip-types
      • #4850 Remove ClassCallCheck, possibleConstructorReturn in loose mode. (@hzoo)
    • πŸ”Œ babel-generator, babel-plugin-transform-flow-strip-types, babel-types

    :bug: Bug Fix

    • πŸ”Œ babel-helpers, babel-plugin-transform-class-properties, babel-plugin-transform-es2015-classes
      • #5885 Fix returning an object in a derived class constructor without super. (@jridgewell)
    • πŸ”Œ babel-helper-remap-async-to-generator, babel-plugin-transform-async-to-generator
    • πŸ”Œ babel-plugin-transform-es2015-modules-commonjs
    • πŸ”Œ babel-plugin-transform-es2015-classes
    • babel-cli
    • babel-types
      • #5865 Fix type errors for destructuring assignments(#4227). (@MarckK)
    • babel-generator
    • πŸ”Œ babel-plugin-transform-numeric-separator
    • πŸ”Œ babel-plugin-transform-es2015-template-literals, babel-preset-es2015
    • πŸ”Œ babel-plugin-transform-es2015-parameters
    • πŸ”Œ babel-plugin-syntax-optional-chaining

    πŸ’… :nail_care: Polish

    • πŸ”Œ babel-plugin-transform-es2015-parameters
    • πŸ— babel-helper-builder-react-jsx, babel-plugin-transform-es2015-spread, babel-traverse
    • babel-traverse, babel-types
    • babel-types

    πŸ“š :memo: Documentation

    :house: Internal

    • babel-polyfill
    • Other
    • babel-core, babel-generator
    • babel-*
    • babel-core, babel-generator, babel-traverse, babel-types
    • babel-*
    • babel-generator, babel-traverse
      • #5866 update babel-eslint, try out numeric separators. (@hzoo)
    • babel-generator
    • babel-cli
    • βœ… babel-core, babel-helper-transform-fixture-test-runner, babel-traverse
    • babel-core, babel-traverse