-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Do not report errors of implicit any during contexual type checking of binding pattern element #8241
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
Conversation
// @noimplicitany: true | ||
let [a, b, c] = [1, 2, 3]; // no error | ||
let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error | ||
let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should having default initializer be "undefined" get an noImplicitAny error? as it is similar to doing this
var x = undefined
or function foo(x=undefined) {}
in both case, the compiler will give an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. It is different than that because destructuring(here a2) gets the typing through rhs (here as number because of rhs assignment of [1,2,3])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it! Thanks. Though, in below case
let [a=undefined] = [];
Should it be an error? (would you add the test in as well?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. 👍 After adding the tests
👍 |
👍 |
I'm not crazy about the extra |
@ahejlsberg Do you have anything in mind because apart from combining options |
@sheetalkamat can you refresh the PR? |
Fixes #8229