Skip to content

Proper eventual-send (wavy-dot, aka tildot) support #11348

@michaelfig

Description

@michaelfig

Feature Request

  • I would like to work on this feature!

Is your feature request related to a problem? Please describe.
The only problem is wanting to land the new "wavy-dot" eventual send syntax (currently stage1) in Babel.

Describe the solution you'd like
Add and implement an ["eventualSend"] parser option.

babel-plugin-syntax-eventual-send and babel-plugin-proposal-eventual-send would be the next steps.

Describe alternatives you've considered
I had a quick hack to get this working (without a clean factoring) in #10115. This current proposal is to implement it the right way according to Babel conventions.

Teachability, Documentation, Adoption, Migration Strategy

Enabling babel-plugin-syntax-eventual-send will enable the "eventualSend" parser plugin. That will emit new nodes in alignment with the proposed syntax:

// foo~.bar
{ type: "EventualMemberExpression", eventual: true, object: foo, property: bar, computed: false }
// foo~.[i]
{ type: "EventualMemberExpression", eventual: true, object: foo, property: i, computed: true }
// foo~.(...args)
{ type: "EventualCallExpression", eventual: true, callee: foo, arguments: args }

Secondly, a new babel-plugin-proposal-eventual-send will actually implement EventualCallExpression|EventualMemberExpression in terms of HandledPromise static methods, including the needed pipelining semantics of optimising a member followed by call as a "method", and rewriting ExpressionStatement expressions whose value is discarded as "send-only" methods.

Shout out to: @erights, @FUDCo, @kriskowal.
I'd appreciate feedback from: @loganfsmyth, @jridgewell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions