69 Commits

Author SHA1 Message Date
Daniel Tschinder
27ad69d43f Fix declare class with qualified type identifier (#97)
This makes declare class extends behave the same way as in flow
The ast-token after the extends keyword, might be either Identifier or
QualifiedTypeIdentifier

To do that this commits splits the parseGenericType into two functions,
one for parsing genericType and on for qualifiedTypeIdentifier
2016-08-23 17:29:23 -04:00
Dan Harper
efab40154e Fix arrow functions with destructuring, types & default value (#94)
Flow's "toAssignable" override wasn't calling the inner function,
resulting in the destructuring in an AssignmentPattern not having the
node type changed from ObjectExpression to ObjectPattern, resulting in
"Binding rvalue" thrown from "checkLVal()"
2016-08-23 17:27:39 -04:00
Daniel Tschinder
db0705bc51 Fix issues with flow-types and async function (#95)
the typeAnnotation was not correctly resolved in async
functions
2016-08-23 17:22:01 -04:00
Sebastian McKenzie
43cdd2f5b0 Merge pull request #57 from danez/fix-arrow-location
Fix arrow param locations with flow types
2016-08-16 15:06:19 +01:00
Sebastian McKenzie
c9a7bed6d0 Merge pull request #83 from gabelevi/flow
Small fix for parsing type parameter declarations
2016-08-04 00:37:37 +10:00
Daniel Tschinder
eb691425b6 Only allow declares inside declare module (#73)
* Only allow declares inside declare module

* Better error message
2016-07-29 20:22:49 +02:00
Gabe Levi
859ed04be9 Small fix for parsing type parameter declarations 2016-07-29 12:45:20 -04:00
Daniel Tschinder
cd987cd8e4 Fix arrow param locations with flow types
This patch corrects the end locations for params in arrow functions
which use type params.
2016-07-28 23:09:19 +02:00
Daniel Tschinder
f576865ce9 Add support for declare module.exports (#72)
* Add support for declare module.exports

* Use doublequotes

* Use expect instead of eat
2016-07-28 22:16:58 +02:00
Max Schaefer
fd18d89d8e Fix accidental fall-through in Flow type parsing. (#82)
When parsing a primary type, `>` would erroneously be treated like `(`.
2016-07-28 22:12:47 +02:00
Daniel Tschinder
4e2072def8
Fix performance regression introduced in 6.8.2
This commit e6c11a0 (#19) made a big performance regression.
The reason was that parseConditional was always cloning the current state
even if no question mark (potential conditional or flow-optional
token) was at the current position.
Simply checking if questionmark matches the current token solves the problem.

Fixes #62
2016-07-03 11:52:01 +02:00
Sebastian McKenzie
d976b56bbe Merge pull request #54 from gabelevi/arrow
[Flow] Arrow function type parameter declarations
2016-06-24 18:36:07 +01:00
Gabe Levi
22374b6bec [Flow] Arrow function type parameter declarations 2016-06-24 10:34:09 -07:00
Vladimir Kurchatkin
f0c7660980 move logic to flow plugin 2016-06-24 20:23:02 +03:00
Sebastian McKenzie
3524ad510f remove grouped type arrow restriction as it seems flow no longer has it - fixes #44 2016-06-22 13:43:32 +01:00
Sebastian McKenzie
ec0a349ec8 support negative numeric type literals - fixes T7450 2016-06-22 13:17:27 +01:00
Sebastian McKenzie
461261b181 Merge branch 'fix-flow-optional-type' of https://github.com/danez/babylon into danez-fix-flow-optional-type
# Conflicts:
#	src/plugins/flow.js
2016-06-22 12:52:42 +01:00
Sebastian McKenzie
4d2e1dddfb Merge pull request #10 from danez/fix-flow-arrow-spread
Fix flow plugin when flow+arrow+spread used together
2016-06-22 12:36:52 +01:00
Gabe Levi
fe5193a40a Support defaults in Flow's type parameter declarations
The primary goal of this commit is to add the ability to parse type parameter
declarations with defaults, like `type Foo<T = string> = T`. While I was in the
code, I fixed a few small things, like

* Type parameter declarations need 1 or more type parameters.
* The existential type `*` is not a valid type parameter.
* The existential type `*` is a primary type
* The param list for type parameter declarations now consists of
  `TypeParameter` nodes
2016-04-27 16:12:10 -04:00
Daniel Tschinder
e6c11a0673 Fix support for flow optional parameters in arrow functions T7096
This overwrites the conditional handling in babylon for flow to support
optional parameters in arrow functions.
2016-04-10 13:06:48 +02:00
Daniel Tschinder
d15a2310cd Fix flow plugin when flow+arrow+spread used together
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)`.
2016-04-04 18:10:58 +02:00
Sam Goldman
b85d6c7e4a Add support for Flow def-site variance syntax
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.
2016-03-06 14:44:09 -08:00
Amjad Masad
9a180797c0 Revert "Remove flow"
This reverts commit 2827ff6b01dcce69e9d3c0402e96b52b3a2a47ee.
2016-03-03 14:49:20 -08:00
Sam Goldman
d6ee428857 Remove flow 2016-03-01 22:33:30 -08:00
Sebastian McKenzie
c9f9435445 Switch to klint, fix some lint rules 2016-02-14 23:25:14 +00:00
Amjad Masad
024cba6433 Merge pull request #3305 from jviereck/T7052
Fix: Arrow functions with trailing comma + return type are throwing an error when parsing
2016-02-05 13:50:57 -08:00
Jeff Morrison
acc946c09e Add support for leading pipes in Flow type alias RHS syntax 2016-02-05 13:23:55 -05:00
Julian Viereck
a121d1b7b5 Fix and tests 2016-01-31 01:22:31 +01:00
Sam Goldman
a04948f70f Add export interface Flow syntax support
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
2016-01-05 15:57:45 -08:00
Sam Goldman
bd5c1a5b1b Add support for "declare interface" Flow syntax
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.
2016-01-04 11:50:12 -08:00
Sam Goldman
0980819346 Add support for "declare type" Flow syntax
See facebook/flow#1105
2016-01-04 11:42:43 -08:00
Sebastian McKenzie
326e157e5d Merge pull request #3203 from samwgoldman/flow-mixins-6.x
Add support for mixins to Babel 6.x
2015-12-27 21:04:40 +00:00
Sam Goldman
137abcaf7a Add support for mixins to Babel 6.x 2015-12-23 16:09:12 -05:00
Sam Goldman
f0fd729883 Add support for this type to Babel 6.x 2015-12-23 13:54:57 -05:00
Henry Zhu
d833e8bbee eslint: add space-after-keywords 2015-12-06 11:30:07 -05:00
Amjad Masad
e3da84bcc3 Add support for null literal type 2015-12-03 23:58:25 -08:00
Aliaksei Shytkin
5e987cd46e Make arrow functions to work with multiple args and flow return type (fixes T2422) 2015-11-23 15:20:16 +03:00
Daniel Lo Nigro
20a483cd58 Fix Flow.
Removed `@flow` annotation from files that don't actually pass Flow check at the moment. These will be added back file by file once the files are properly converted to use Flow.

Closes #3064
2015-11-15 21:30:22 -08:00
Sebastian McKenzie
779675610f fix defaults on type annotated arrow function params - fixes #2493 2015-11-05 09:49:03 +00:00
Sebastian McKenzie
2b6f78df83 fix existential type param parsing 2015-11-03 20:04:55 +00:00
Sebastian McKenzie
4016bae694 add ExistentialTypeParam - fixes #2587 2015-11-03 13:48:03 +00:00
Sebastian McKenzie
ea40d0134f rename NumberLiteral to NumericLiteral and RegexLiteral to RegExpLiteral 2015-11-03 01:19:35 +00:00
Sebastian McKenzie
c224a7a370 fix parser bug where arrow functions have a higher precedence than they should - fixes #2118 2015-10-30 22:50:53 +00:00
Sebastian McKenzie
b909a81ab7 6.0.0
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.
2015-10-29 17:51:24 +00:00
Sebastian McKenzie
6d6ddf0bcd type annotate babylon 2015-09-23 15:59:41 +01:00
Sebastian McKenzie
d97240ae09 Merge remote-tracking branch 'origin/master' into development
Conflicts:
	packages/babel/scripts/build-dist.sh
2015-08-27 11:12:00 -07:00
Cesar Andreu
bc59b09f6b Start ObjectTypeProperty's optional property as false in each loop 2015-08-27 00:07:26 -04:00
Sebastian McKenzie
8887444cf7 fix various bugs surfaced by the esprima test suite, remove some incorrect tests 2015-08-11 16:58:20 +01:00
Sebastian McKenzie
df021c7f23 add esprima tests and fix bugs picked up by it 2015-08-11 00:59:15 +01:00
Sebastian McKenzie
c318c88050 forward all arguments to parseClassId in flow parser plugin 2015-08-10 13:10:32 +01:00