proposal-block-params
proposal-block-params copied to clipboard
Syntax confliction
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...
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.