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
Allow TypeScript type assertions in array destructuring #10592
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
[a as number] = arr
?
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.
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