Skip to content

Destructured parameter properties do not introduce properties into their respective class #1541

Closed

Description

class C {
    constructor(public [x, y, z]: string[]) {
    }
}

var c = new C([]);
c.x === c.y;

which gives us

error TS2339: Property 'x' does not exist on type 'C'
error TS2339: Property 'y' does not exist on type 'C'

The question is should we be adding properties when destructuring in the face of a visibility modifier?

Activity

  1. added
    SpecIssues related to the TypeScript language specification
    and removed
    QuestionAn issue which isn't directly actionable in code
    on Jan 8, 2015
  2. DanielRosenwasser commented on Jan 13, 2015

    @DanielRosenwasser
    MemberAuthor

    jonathandturner and I spoke offline and decided that the binding parameters should introduce properties of the appropriate visibility.

  3. DanielRosenwasser commented on Jan 14, 2015

    @DanielRosenwasser
    MemberAuthor

    Anders Hejlsberg (@ahejlsberg) and I spoke offline and decided that binding parameters should not introduce properties of the appropriate visibility.

  4. mhegazy commented on Jan 15, 2015

    @mhegazy
    Contributor

    Reopening to update the spec.

  5. DanielRosenwasser commented on Jan 15, 2015

    @DanielRosenwasser
    MemberAuthor

    This is Fixed as far as the work goes; the spec work needs to be done.

  6. danquirk commented on Jan 15, 2015

    @danquirk
    Member

    Let's create new bugs for spec work, that way you can close this with the fixed label. Otherwise we should remove the fixed label from this one, which then makes confusing the fact that it does represent dev work that fixed an issue.

  7. DanielRosenwasser commented on Jan 16, 2015

    @DanielRosenwasser
    MemberAuthor

    Agreed; I've opened up #1691 instead.

  8. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions