-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Object destructuring broken: variables are bound to the wrong object #9363
Comments
@yuit can you take a look. |
@yuit fyi, in a function with two parameters, each representing objects with properties that can be destructured, it doesn't matter whether the function expects something or nothing from any of these objects, if either null or undefined is passed in to either of these parameters by the client code, an exception should be raised. Example: function something({}, {foo, bar}) {
// ...
}
function another(viaIdentifier, { foo, bar }) {
// ...
}
something(undefined, { foo: 'foo', bar: 'bar' });
// This is an ERROR, because the first parameter is set to undefined, and the
// function `something` was declared to have the first parameter be
// destructured, even if we aren't asking for any properties from it
another(undefined, { foo: 'foo', bar: 'bar' });
// This is perfectly fine, because the first parameter is not destructured in
// function declaration of `another` |
@shovon I got the fix for the first comment. I am investigating your second comment |
@shovon I have another PR to fix your second comment, if you would like to take a look ! |
TypeScript Version: 1.8.10
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: