-
-
Notifications
You must be signed in to change notification settings - Fork 258
Conditional MemberAccess (Null propagation) #205
Comments
Hi,
I have not found any discussion about it in TC39. Maybe you could make your suggestion as proposals in TC39. Here is an discussion about "condition member access" in microsoft/TypeScript#16 - maybe interesting for you! |
Hi @kristofdegrave, Thanks for the interest in contributing to Babylon! @SerkanSipahi is correct that the project only accepts PRs right now for TC39 proposals that are at Stage 0 or higher. There has been some discussion around a proposal on ESDiscuss, but nothing official yet. It might be worth taking a look at Sweet.js, which lets you write hygienic macros for JavaScript. |
@SerkanSipahi @DrewML Thanks for the feedback. Too bad it is not possible at the time, but let's hope it will come to es6 :). I'll leave the forks maybe sometime in the future they will become useable. |
@kristofdegrave "condition member access" is not part of es6. |
It looks like what I was trying to add is already a stage 1 proposal: Does this mean you can take this under consideration? If so can you let me know what the next steps should be for getting the PR merged? |
@kristofdegrave see #328 ! i think they are looking for someone who can implement that :) |
Nice, working on It. ;) |
…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.
Hi. Thank you. |
Check #328 |
Hi,
I would like to add conditional member access to babel. This must allow developers to access the members of an object conditionally. This means they no longer need to check if the object is undefined before accessing the member of the object.
The syntax I use for this is "?." and "?[".
So before I can add a transformer for this in the babel project I need to adjust babylon so "?." and "?[" get recognized as member access but in a conditional form. I already created a fork on which I committed some code to do the parsing and handeling.
I guess before I can create a pull request you probably want some tests added for this. This is where it is getting unclear for me. I don't know where I should add the test for this functionality. Can anyone help me with this?
I have also added the transformer on a fork of babel so you can get an idea where I want to go. https://github.com/kristofdegrave/babel/tree/master/packages/babel-plugin-transform-conditional-member-access
The text was updated successfully, but these errors were encountered: