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.
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.
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.
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.
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