Skip to content

Destructuring of private named instance field doesn't count as read #35935

Description

TypeScript Version: 3.8.0-dev.20191228

Search Terms:

Code

class C{
    #prop = 1;
    method() {
        const { #prop: prop } = this;
        ({ #prop: this.#prop } = this);
    }
}

Expected behavior:

No error as the property is read by the destructuring binding and the destructuring assignment.

Actual behavior:

'#prop' is declared but its value is never read.(6133)

Playground Link: https://www.typescriptlang.org/play/?ts=3.8.0-dev.20191228&ssl=7&ssc=2&pln=1&pc=1#code/MYGwhgzhAEDCDeAoaLoGIAOAnA9h6AvNAIwDcyqAtgKYAuAFjgCYAUAlNEqt9MDgHYRandNjwAuaGPwBfQtAYBLCOR6oW8UbgySlEAHSZt0OUT1tVqGYhlA

Related Issues: #35934 /cc Max Heiber (@mheiber) Titian Cernicova-Dragomir (@dragomirtitian)

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