Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.
/ babylon Public archive
This repository was archived by the owner on May 19, 2018. It is now read-only.

Conditional MemberAccess (Null propagation) #205

@kristofdegrave

Description

@kristofdegrave

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions