Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add optional chaining to the babel preset #287

Closed
wants to merge 1 commit into from

Conversation

edas
Copy link
Contributor

@edas edas commented Feb 15, 2019

Optional chaining
allows to chain potentially null components.

Instead of doing

if (window && window.location && window.location.protocol) {
  ssl = window.location.protocol
}

we could do

ssl = window?.location?.protocol

The spec is stage 1 only but they seem to have reach consensus
and the formal stage 2 decision should be in March

There should not be any compatibility break

@edas edas requested a review from CPatchane as a code owner February 15, 2019 18:27
@edas edas requested a review from ptbrowne February 15, 2019 18:47
[Optional chaining](https://github.com/tc39/proposal-optional-chaining)
allows to chain potentially null components.

Instead of doing
```
if (window && window.location && window.location.protocol) {
  ssl = window.location.protocol
}
```
we could do
```
ssl = window?.location?.protocol
```

The spec is stage 1 only but [they seem to have reach consensus](tc39/proposal-optional-chaining#75 (comment))
and [the formal stage 2 decision should be in March](tc39/proposal-optional-chaining#76 (comment))

There should not be any compatibility break
@edas edas force-pushed the feat/optional-chaining branch from b7b005e to 461ce42 Compare February 18, 2019 13:17
@edas edas closed this Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants