Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Include static keyword in method toString #34

Open
jridgewell opened this issue Aug 21, 2018 · 2 comments
Open

Include static keyword in method toString #34

jridgewell opened this issue Aug 21, 2018 · 2 comments

Comments

@jridgewell
Copy link
Member

Static is currently excluded from a method's toString:

class Ex {
  static test() { /* hello */ }
}

console.log(Ex.test.toString());
// => 'test() { /* hello */ }'

The decorators group would like to include it in the toString, since it can't go before the decorators.

@ljharb
Copy link
Member

ljharb commented Aug 21, 2018

Even unrelated to decorators, it makes sense, and follows the mental model, that if you eval Ex.test.toString() inside a similar lexical context (the body of class Ex, with the same variable bindings in scope) that it should result in a static method.

@littledan
Copy link
Member

Intutiively, I like this change. To me, it seems like static is part of the method declaration just as much as async is. I don't think we should put too much stock into the details of a particular version of the spec's grammar when making these sorts of decisions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants