-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Inline type annotations for rebinded destructuring parameters #3828
Comments
I don't think we could use that specific ordering given that we've added a new |
The |
Sorry, what I really meant by that is that it would be confusing to do so. Users would have to remember that
|
In #1 I'm suggesting to use "as" in object binding patterns as well (which contradicts to ES6 and may have problems with nested destructuring): |
We need to just leave this area alone -- there's too much room for conflict with ES7+ activity, and adding any more syntax or variations is more likely to increase confusion than decrease it (as we've seen with the ES6 module import syntax). |
I've seen a discussion around this in Flow, but couldn't find one here. The discussion was around this (desired, but not actual) syntax:
This is what a ts user expects to write and this is what I often mistakenly write despite I'm quite familiar with ts. The problem with this syntax is known: it conflicts with the ES6 spec which says that
{ a: number }
meanslet number = arguments[0].a
However, in the syntax for importing stuff from modules, ES6 spec uses a different syntax:
Which I personally find easier to understand, but what's more important is that it leaves a room for a ts type annotation:
What I'm asking for is probably an unheard of thing: can ts deviate from the ES6 spec in this particular place and treat
{ b: string as b2 }
syntax as "parameter b of type string rebinded to variable b2"?The text was updated successfully, but these errors were encountered: