Skip to content

Commit

Permalink
Add blog post for v7.2.0 (#1906)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 3, 2018
1 parent 8b07f75 commit 77376e2
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions website/blog/2018-12-03-7.2.0.md
@@ -0,0 +1,80 @@
---
layout: post
title: "7.2.0 Released: Private Instance Methods"
author: Nicolò Ribaudo
authorURL: https://twitter.com/NicoloRibaudo
date: 2018-12-03 12:00:00
categories: announcements
share_text: "Babel 7.2.0 Released"
---

We just released a new minor version of Babel!

This release includes support for private instance methods and a bunch of bug fixes regarding Flow and TypeScript types. You can read the whole changelog [on GitHub](https://github.com/babel/babel/releases/tag/v7.2.0).

<!-- truncate -->

A lot of new contributors fixed bugs or implemented new features in this release: thanks to [Gcaufy](https://github.com/Gcaufy), [Grigory Moroz](https://github.com/morozRed), [Paul Happ](https://github.com/phapp88), [Tim McClure](https://github.com/tim-mc) and [Veaceslav Cotruta](https://github.com/katrotz)!

A big shout out to Bloomberg for sponsoring the implementation of private class elements! This support for private _instance_ methods is a follow-up to private _static_ fields released in Babel [7.1.0](https://babeljs.io/blog/2018/09/17/7.1.0#private-static-fields-stage-3).

If you or your company wants to support Babel and the evolution of JavaScript, but aren't sure how, you can donate to us on [OpenCollective](https://opencollective.com/babel) and, better yet, work with us on the implementation of [new ECMAScript proposals](https://github.com/babel/proposals) directly!

## Highlights

### Private Instance Methods ([#8654](https://github.com/babel/babel/pull/8654))

```javascript=
class Person {
#age = 19;
#increaseAge() {
this.#age++;
}
birthday() {
this.#increaseAge();
alert("Happy Birthday!");
}
}
```

Thanks to [Tim](https://github.com/tim-mc) for implementing this proposal, and to [Nicolò](https://twitter.com/NicoloRibaudo) and [Justin](https://github.com/jridgewell) for the reviews!

You can test private methods by adding the `@babel/plugin-proposal-private-methods` plugin to your Babel configuration, or enabling the `stage-3` preset in the [repl](https://babeljs.io/repl/build/master#?presets=stage-3).

Private accessors [are also coming](https://github.com/babel/babel/pull/9101), and we have done some big internal refactoring that allows us to add support for private elements to decorators soon :tada:.

### "Smart" Pipeline Operator Parsing ([#8289](https://github.com/babel/babel/pull/8289))

Thanks to the work of [James DiGioia](https://github.com/mAAdhaTTah), `@babel/parser` now also supports the [Smart Pipeline Operator](https://github.com/js-choi/proposal-smart-pipelines/), in addition to the [Simple](https://github.com/tc39/proposal-pipeline-operator) version.

We currently only support the "core" of the smart pipeline proposal, and not the additional features.

```javascript=
// "Smart"
const result = 2 |> double |> 3 + # |> toStringBase(2, #); // "111"
// "Simple"
const result = 2 |> double |> (x => 3 + x) |> (x => toStringBase(2, x));
```

Babel implements multiple variants of this proposal to help TC39 test and gather feedback from the community. As with all proposals, expect changes in the future.

If you are directly using `@babel/parser` and you want to test this proposal, you can pass the `proposal: "smart"` option to the pipeline plugin:

```javascript=
const ast = babel.parse(code, {
plugins: [
["pipelineOperator", { proposal: "smart" }]
]
})
```

We don't support transpiling this syntax yet, but it will come soon.

### Plugin Names ([#8769](https://github.com/babel/babel/pull/8769))

Every official plugin now provides Babel its name. Although this doesn't affect normal Babel use, it provides a consistent identifier for each plugin. This is particularly useful for things like [Time Travel](https://github.com/babel/website/pull/1736), which allows you to see exactly what each plugin is doing to your code. You can see this in effect via our [repl](https://babeljs.io/repl/build/master#?timeTravel=true):

![](https://i.imgur.com/AzKc37i.gif)

0 comments on commit 77376e2

Please sign in to comment.