Skip to content

Support destructuring-private #13889

@JLHwung

Description

@JLHwung

💻

  • Would you like to work on this feature?

What problem are you trying to solve?

Destructuring Private proposal just reached Stage 2. Babel should support parsing as well as transforming this feature.

Describe the solution you'd like

For parsing, we can add a new parser plugin DestructuringPrivate and extend parseObjectProperty to cover new syntax.

For transforming, we should only transform the private destructuring. For example,

// In
const { #x: x, y = x, #z: { #w: w, ...v } } = o;

// Out
const x = o.#x;
const { y = x } = o;
const o$z = o.#z;
const w = o$z.#w;
const { ...v } = o$z; // private fields are not enumerable and thus `v` should not contain `#z`

Describe alternatives you've considered

For transforming, we can also run the full destructuring transform, but the output will be more verbose.

Documentation, Adoption, Migration Strategy

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions