Skip to content

ES6 destructuring with this variable - tuple and array #10076

Closed
@Guardiannw

Description

@Guardiannw

TypeScript Version: 1.8.10
Code

// A *self-contained* demonstration of the problem follows...
var array = [1, 2, 3];
[this.test, this.test2, this.test3] = array;

Expected behavior:
for it to compile as _this.test = array[0], _this.test2 = array[1], _this.test3 = array[2];
Actual behavior:
it compiles as _this.test = array[0], this.test2 = array[1], this.test3 = array[2];

This is a problem because the this scope does not match correctly that of the lambda.

Metadata

Metadata

Assignees

No one assigned

    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