Allow TypeScript type assertions in array destructuring#10592
Allow TypeScript type assertions in array destructuring#10592nicolo-ribaudo merged 5 commits intobabel:masterfrom
Conversation
SakibulMowla
commented
Oct 22, 2019
| Q | A |
|---|---|
| Fixed Issues? | Fixes #10066 |
| Patch: Bug Fix? | Yes |
| Major: Breaking Change? | No |
| Minor: New Feature? | No |
| Tests Added + Pass? | Yes |
| Documentation PR Link | |
| Any Dependency Changes? | No |
| License | MIT |
| contextDescription: string, | ||
| ): $ReadOnlyArray<N.Pattern> { | ||
| const isAssignmentExpression = | ||
| contextDescription === "assignment expression"; |
There was a problem hiding this comment.
I would prefer not to rely on the exact value of this string, since it's only used for error messages. Could we use !isBinding instead of isAssignmentExpression?
There was a problem hiding this comment.
Highly agree on not using the value of the string. What does isBinding represent? Can you point me to any doc or link?
There was a problem hiding this comment.
In JavaScript, bindings (1, 2) are what you use to declare a variable. For example, in var { x } = {}, { x } is a binding pattern and x is a binding identifier. On the other hand, in ({ x } = {}) there isn't any binding because you aren't declaring anything new (you are reassigning an existing variable).
| @@ -0,0 +1 @@ | |||
| (a as number) = 42; | |||
There was a problem hiding this comment.
Shouldn't this be:
[a as number] = arr?
There was a problem hiding this comment.
It sure should be. Was playing around with input and forgot to change it back. Thanks for noticing!
cecc5d6 to
2b372b9
Compare
2b372b9 to
35786c7
Compare