proposal-block-params icon indicating copy to clipboard operation
proposal-block-params copied to clipboard

Syntax confliction

Open hax opened this issue 6 years ago • 1 comments

f(arg) {
   ...
}

As current syntax of this proposal, such code will have different semantic in/not in the class body, which is very confusing, error-prone, and harm to code review.

Another example of error:

const x = {
  key: () => {...}
}

Someone may refactor the code from arrow function to plain function for some reason (for example, need name for recursion), and just forgot the function keyword:

const x = {
  key: f() {...}
}

Currently it will cause syntax error, with this proposal, oops...

hax avatar Jul 02 '19 10:07 hax

const x = {
  key: f() {...}
}

becomes

const x = {
  key: f(() => {...})
}

and unless f is defined, you are still getting a ReferenceError. And if f is defined, x.key might not be a function, leading to another error. You'll have to be really lucky if f returns a function.

SiddharthShyniben avatar Aug 28 '21 08:08 SiddharthShyniben