Skip to content

bug: exception with destructuring assignment with private fields #9310

Description

@dnalborczyk

Bug Report

Current Behavior
Invalid destructuring assignment target exception with destructuring assignment with private fields

Input Code

class Foo {
  #client

  constructor(props) {
    ;({ client: this.#client } = props) // throws: Invalid destructuring assignment target
  }
}

transpiles to (excerpt):

({
  client: _classPrivateFieldGet(this, _client)  // notice the getter
} = props);

Environment

  • Babel version: v7.2.2

update:

I suppose it would need to use _classPrivateFieldSet as well as transpile the ES2015 destructuring assignment? unless destructuring assignments work with a function call ... which I don't think it does?

var client = props.client
_classPrivateFieldSet(this, _client, client);

for what it's worth: works in node --harmony v11.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Spec: Class FieldsoutdatedA 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