-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Rest parameters and default parameters #1779
Comments
Hello, +1 main.expr.parse = function parse(expression = '', scope) {
};
An idea to fix this ? |
Sorry, lost track of this one, thanks for the bump. |
Super :) |
Should the "Regular parameters cannot come after default parameters" error even exist at all? AFAIK this is valid: function f(a = 1, b) {
console.log(a, b); // 1, 2
}
f(undefined, 2); Yet JSHint throws the aforementioned error. |
you're right, it doesn't make much sense :< (https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization) |
It could be downgraded to a warning/config option IMO (e.g. useful for people that consider it a bad practice). |
If downgrading to a warning/config is preferred, I guess a new issue should be opened to track the progress on it. If the error is removed altogether, then it fixes both OP's and my issue. |
ever since at least draft rev 20 (from 10/2013), the workings have been "initializers can go anywhere, and just replace undefined values". I don't have any older drafts, so maybe this was different at some point. Anyways, we should probably just delete the warning, it's kinda bogus |
@rwaldron wdyt? |
There are two things here:
|
Any preference on whether to convert to a warning or remove outright ? Not sure what you mean by |
JSHint reports
Regular parameters cannot come after default parameters
if you use both default parameter and rest parameter, but I think this is a valid use case:The text was updated successfully, but these errors were encountered: