Skip to content

Lexer: Backticks should allow adding code to class body #4464

@wcjohnson

Description

@wcjohnson

ES2015 spc allows method definitions to be prefixed by get or set in which case they are transformed to property getters and setters.

Of the following, only A generates the corresponding ES2015 output:

class A
	x: -> 42

class B
	get x: -> 42

class C
	`get` x: -> 42

class D
	`get x`: -> 42

class E
	`get x() { return 42; }`

B makes a hoisted class body (as expected), C and D are syntax errors, and E, which would seem like it should be the ultimate escape valve, generates a hoisted class body as well.

It would be nice to have some kind of escape valve for modifying the definitions within the non-hoisted portion of ES2015 class body. It would be particularly nice if backticks could be made to serve this function, as they can help support other possible future syntax (e.g. decorators) as well.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions