Skip to content

Destructuring assignment #4

Description

@Trildar

Relevant pages:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
https://www.typescriptlang.org/docs/handbook/variable-declarations.html

This can be supported by creating temporary variables and then doing assignment from those variables, much like how the regular TypeScript compiler does it.
e.g. let [a, b] = [1, 2] could translate to local _a = {1, 2}; local a = _a[1]; local b = _a[2] or separate the declaration of the variables to another line if possible, to avoid having local a bunch of times.

let [a, b] = [1, 2] could also technically translate to local a, b = 1, 2, but I'm not sure trying to recognise when multiple assignment can be used would be worth it.

Supporting ...rest would probably need some helper function, since Lua doesn't have an equivalent to JavaScript's Array.prototype.slice.

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