facebook/esprima — pull request #65 by gabelevi (2014-10-27 20:40:08+00:00)
Title: Intersection types and grouped types

So we already have union types, which look like `var a: Foo | Bar` and mean that `a` is either a `Foo` or a `Bar`. Intersection types look like `var a: Foo & Bar` and mean that `a` is both a `Foo` and a `Bar`. I have made the `&` operator bind more tightly than `|`, so `A | B & C` parses as `Union(A, Intersection(B, C))`.

In order to disambiguate I have also added the ability to use parens to group types together. For example,
`(A | B) & C` means `Intersection(Union(A, B), C)`. These parens also let you specify types that weren't possible before, like `(() => number) | (() => string))`. This is necessary because `() => number | () => string` would have been parsed as a function that returns either a `number` or a `() => string`.

This is built on top of https://github.com/facebook/esprima/pull/64 which I suppose didn't really need to be it's own pull request.

Test plan: npm test and ran the esprima tester