The fix includes creating a new method on the parser called `parseArrow`.
This new function by default only checks if current position matches an
arrow. If it does returns the `node` otherwise `undefined`.
The flow plugin can then extend this function and correctly parse the typeAnnotation
and add it to the node.
With this change, in the flow plugin there is no need anymore to extend
`parseParenAndDistinguishExpression` and the arrow handling in `parseParenItem`
could also be removed, because it is all handled now in `parseArrow`.
Some existing tests were failing, because `extra->parentesized` is now missing,
but this is correct as it is now inline with parsing without flow annotation. No extra
is added for arrow function without type annotations.
In the expression-parser `this.next()` was replaced by a more specific
`this.expect(tt.parenL)`.
This syntax allows you to specify whether a type variable can appear in
a covariant or contravariant position, and is super useful for, say,
Promise.
Right now this is hacked in jankily, but in the next major release we
should stop using Identifier nodes for type parameters.
An interface export is just like a type export. In fact, it's a syntax affordance which makes the following equivalent:
```javascript
interface I_ { ... }
export type I = I_;
```
```javascript
export interface I { ... }
```
See facebook/flow#1145
This has been a feature in Flow for a long time (couldn't easily find a
specific commit adding this). Interfaces are basically undocumented, though, so
it's easy to see how this was missed.
For example:
var foo = function () {
"use strict";
"use strict";
// there is inside of strict mode,
// so `0123` (octal number) occurs a syntax error.
};
// there is outside of strict mode,
0123; // so left is valid syntax.
// however:
// SyntaxError: Invalid number (8:0)
I fixed it and add the test case.
I'm extremely stupid and didn't commit as I go. To anyone reading this
I'm extremely sorry. A lot of these changes are very broad and I plan on
releasing Babel 6.0.0 today live on stage at Ember Camp London so I'm
afraid I couldn't wait. If you're ever in London I'll buy you a beer
(or assorted beverage!) to make up for it, also I'll kiss your feet and
give you a back massage, maybe.