This repository has been archived by the owner. It is now read-only.

Optional Chaining: Stage 1 #328

Closed
hzoo opened this Issue Jan 27, 2017 · 12 comments

Comments

Projects
None yet
10 participants
@hzoo
Copy link
Member

hzoo commented Jan 27, 2017

TC39 Proposals: https://github.com/tc39/proposals

Stage: 1, Gabriel Isenberg, Claude Pache

Proposed at TC39 Meeting: https://github.com/tc39/agendas/blob/master/2017/01.md#agenda-items
Spec Repo: https://github.com/tc39/proposal-optional-chaining
Slides: https://docs.google.com/presentation/d/11O_wIBBbZgE1bMVRJI8kGnmC6dWCBOwutbN9SWOK0fU/edit#slide=id.p

ESTree Issue to discuss AST Spec: estree/estree#146

cc @gisenberg if you can implement or work with someone to do so. (Please join our slack if you haven't http://slack.babeljs.io/)


Babylon PR: #545
Babel PR: babel/babel#5786

@gisenberg

This comment has been minimized.

Copy link
Member

gisenberg commented Jan 30, 2017

Thanks for looping me in! I wanted to let everyone know that I'm over in the BabelJS Slack if there are others that would like to discuss this feature further. I'm currently working with @bmeck on the Babel side of things.

@kristofdegrave

This comment has been minimized.

Copy link

kristofdegrave commented Feb 11, 2017

I'm currently werking on An PR for this

kristofdegrave pushed a commit to kristofdegrave/babylon that referenced this issue Feb 11, 2017

Kristof Degrave Kristof Degrave
babel#328 babel#205 ?. as nullPropagation. For now it only works for …
…member access. (.? or ?.[) If the object is undefined this will return undefined. If the object on which you want to access the property is defined, the value of the propery will be given back.
@sunnylqm

This comment has been minimized.

Copy link

sunnylqm commented Mar 14, 2017

Any news? @kristofdegrave

@rattrayalex

This comment has been minimized.

Copy link
Contributor

rattrayalex commented Mar 16, 2017

As discussed in the babel slack, I'm also interested in contributing to this once the spec is a bit more settled.

I previously implemented a ?. feature for LightScript (a fork/superset of JS built on babylon/babel). In case it helps anyone, here is:

  • The babel transform
  • The associated tests
  • The commit adding the feature to the lightscript parser (a fork of babylon). It uses poor naming ("elvis operator" isn't accurate) and isn't backwards-compatible; a different approach would be necessary.

My version doesn't currently support assignments or delete, though I may add those soon.

For now I'll wait for a bit to hear back from @kristofdegrave and the babel team as to whether the spec seems stable.

@cusspvz

This comment has been minimized.

Copy link

cusspvz commented Mar 31, 2017

Can't wait to see this on ES. Inspite of it being yet at stage-1, it is the only thing that I've always wanted to be part of EcmaScript since I stopped using CoffeeScript. I wish I had spare time to implement it.

@thomaschaaf

This comment has been minimized.

Copy link

thomaschaaf commented May 24, 2017

@gisenberg @kristofdegrave is this still something you are working on? Do you need help?

@hzoo hzoo changed the title Null Propagation Operator: Stage-1 Null Propagation Operator: Stage 1 May 26, 2017

@xtuc

This comment has been minimized.

Copy link
Member

xtuc commented May 26, 2017

Based on @kristofdegrave's work, I can make a PR with this master...xtuc:feat-optional-chaining

I have the Babel part as well babel/babel@7.0...xtuc:feat-optionnal-chaining

I currently only support the basic syntax:

a?.b = 42
delete a?.b
foo?.bar()
@gisenberg

This comment has been minimized.

Copy link
Member

gisenberg commented May 26, 2017

@thomaschaaf This is still underway. If you're interested in helping, https://github.com/gisenberg/proposal-optional-chaining is tracking the remaining work. I'm also in the BabelJS Slack if you want to reach out directly.

@hzoo

This comment has been minimized.

Copy link
Member

hzoo commented May 27, 2017

@xtuc, @kristofdegrave Let's start the PR so we can make a review by us + Gabe?

@xtuc xtuc referenced this issue May 28, 2017

Merged

Optional Chaining: Stage 1 plugin #545

1 of 1 task complete

@hzoo hzoo added the Has PR label May 28, 2017

@hzoo hzoo changed the title Null Propagation Operator: Stage 1 Optional Chaining: Stage 1 May 30, 2017

@hzoo

This comment has been minimized.

Copy link
Member

hzoo commented Jun 5, 2017

The babylon PR is merged (#545)

Please help review/test the transform PR babel/babel#5813

@littledan

This comment has been minimized.

Copy link

littledan commented Jun 6, 2017

For context, at the TC39 meeting where this proposal was presented, there were a couple concerns raised about the scope of the proposal, one syntactic and one semantic. I've filed two issues to discuss these issues. This is a Stage 1 feature and subject to change!

@xtuc xtuc closed this Jul 4, 2017

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