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

Nullish Coalescing (Stage 1) #14

Open
hzoo opened this Issue Jul 21, 2017 · 7 comments

Comments

Projects
None yet
6 participants
@hzoo
Member

hzoo commented Jul 21, 2017

Champions: @gisenberg
Spec Repo: https://github.com/gisenberg/proposal-nullary-coalescing
First presented at the July 2017 meeting: slides
Moved to Stage 1 at the Sept 2017 meeting: slides

Syntax

a ?? b

When performing optional property access in a nested structure in conjunction with the optional chaining operator, it is often desired to provide a default value if the result of that property access is null or undefined. At present, a typical way to express this intent in JavaScript is by using the || operator.

so most use const variable = a || b but a falsy value like 0 or '' or false will unintentionally return b as the value.

Notes:

While this proposal specifically calls out null and undefined values, the intent is to provide a complementary operator to the optional chaining operator. This proposal will update to match the semantics of that operator.

Parsing

  • a new node type name (operator)?
  • pluginName?

https://twitter.com/littledan/status/908032146484469761
https://github.com/babel/babylon/pull/742/files#r142008197

@hzoo hzoo added the Proposal Issue label Jul 21, 2017

@jridgewell

This comment has been minimized.

Show comment
Hide comment
@jridgewell

jridgewell Jul 21, 2017

Member

logicalCOALESCE? Too much of a mouthful? logicalQQ?

Member

jridgewell commented Jul 21, 2017

logicalCOALESCE? Too much of a mouthful? logicalQQ?

@gisenberg

This comment has been minimized.

Show comment
Hide comment
@gisenberg

gisenberg Jul 27, 2017

Member

I started referring to this as the existential operator in the slides.

Member

gisenberg commented Jul 27, 2017

I started referring to this as the existential operator in the slides.

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Jul 27, 2017

Member

@gisenberg feel free to edit the title/etc (if your in the tc39 team it gives you write access to this repo)

Member

hzoo commented Jul 27, 2017

@gisenberg feel free to edit the title/etc (if your in the tc39 team it gives you write access to this repo)

@ljharb

This comment has been minimized.

Show comment
Hide comment

ljharb commented Jul 27, 2017

@hzoo hzoo changed the title from Nullary Coalescing (Stage 0) to Nullary Coalescing (Stage 1) Sep 28, 2017

@hzoo hzoo referenced this issue Sep 28, 2017

Open

Sept 2017 #28

2 of 11 tasks complete
@azz

This comment has been minimized.

Show comment
Hide comment
@azz

azz Oct 15, 2017

Member

Parser PR: babel/babylon#761, follow-up: babel/babylon#762
Transform PR: babel/babel#6483

Member

azz commented Oct 15, 2017

Parser PR: babel/babylon#761, follow-up: babel/babylon#762
Transform PR: babel/babel#6483

@ljharb ljharb changed the title from Nullary Coalescing (Stage 1) to Nullish Coalescing (Stage 1) Oct 15, 2017

@vjpr vjpr referenced this issue May 7, 2018

Open

Tooling implementation status #29

4 of 4 tasks complete
@vjpr

This comment has been minimized.

Show comment
Hide comment
@vjpr

vjpr May 7, 2018

What is the status of this? Is it ready to use?

vjpr commented May 7, 2018

What is the status of this? Is it ready to use?

@azz

This comment has been minimized.

Show comment
Hide comment
@azz

azz May 7, 2018

Member

Yes, just enable the @babel/plugin-proposal-nullish-coalescing-operator plugin.

https://www.npmjs.com/package/@babel/plugin-proposal-nullish-coalescing-operator

Member

azz commented May 7, 2018

Yes, just enable the @babel/plugin-proposal-nullish-coalescing-operator plugin.

https://www.npmjs.com/package/@babel/plugin-proposal-nullish-coalescing-operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment