Skip to content

Destructuring with private and protected members #7124

Closed

Description

@xLama
class Foo {

    private sayFoo = () => {
        console.log('Foo')
    }

}

let foo = new Foo();
foo.sayFoo() // Error. It´s ok.

let {sayFoo} = foo;
sayFoo() // 'Foo' 

Is it by design?

Activity

  1. added
    By Design
    Question
    Bug
    and removed
    By Design
    Question
    on Feb 17, 2016
  2. DanielRosenwasser commented on Feb 17, 2016

    @DanielRosenwasser
    Member

    Clearer case:

    class Foo {
        private prop;
    }
    let foo = new Foo();
    
    let a = foo.prop;
    let { prop: b } = foo;
    let { prop } = foo;

    foo.prop in the declaration of a causes an error because prop is private. The destructuring cases don't.

  3. added
    Fixed
    Breaking Change
    on Feb 26, 2016
  4. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Breaking ChangeBugFixed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions