Skip to content

Support computed property assignments #16

@Swatinem

Description

@Swatinem
for (const name of ["a","b","c"]) {
    Foo.prototype[name] = function () {
    };
};

The anonymous function is resolved to the name Foo.prototype which is not quite correct. In this case best we could do is Foo.prototype[name].
In case the thing in brackets is a literal, we can also put that in there, if its a valid identifier, we can also convert it back to a "normal" property:

  • Foo.prototype[1] -> Foo.prototype[1]
  • Foo.prototype["not a valid ident"] -> Foo.prototype["not a valid ident"]
  • Foo.prototype["valid_ident"] -> Foo.prototype.valid_ident

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions