Skip to content

Compiles to invalid JS: computed class property #5204

Closed
@helixbass

Description

@helixbass

@GeoffreyBooth I came across this while working on class AST:

This:

class A
  [b]: 3

compiles to:

var A;

A = (function() {
  class A {};

  A.prototype.[b] = 3;

  return A;

}).call(this);

which doesn't parse

Does it make sense to allow computed class properties like this?

If so, it's probably just a question of omitting the . when compiling (so here generate A.prototype[b] = 3 instead)?

Fwiw, it looks like this didn't compile (as Coffeescript source) in Coffeescript 1.x. I didn't trace when it became allowed Coffeescript syntax

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions