-
Notifications
You must be signed in to change notification settings - Fork 14
Special casing class/function declarations to have completion semantics #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Trying to disguise function declarations into expressions raises some issues, however.
"use strict";
(do {
if (true) {
let x = 4;
y = f(x);
y + 2;
function f(x) {
return x*10;
}
}
}) As currently specced, the do-expression evaluates to
(do {
if (flag) {
function () {...};
} else {
function () {...};
}
}) but this is a syntax error, as the |
I think it would be better to just outright ban function declarations from Another option is treating function declarations by different semantics in As for |
The current proposal bans all declarations, including |
The completion value of class and function declarations are
undefined
.From my understanding, there hasn't been much of a use case for completion values of class and function declarations in the past, but it can be a valid use case as do-expressions become more popular. Consider the following JSX:
In the above example, the
onClick
handler will be assigned a value ofundefined
, which is probably not what the user would intend from writing the code.Is there a way to special case these so that they have completion semantics?
e.g.
There may also be other such declarations with similar concerns.
The text was updated successfully, but these errors were encountered: