408 Commits

Author SHA1 Message Date
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
97325592fa Fix exponential operator to behave according to spec (#75) 2016-07-17 11:08:12 +02:00
Sebastian McKenzie
3fad8cc9a7 Merge pull request #42 from calebmer/feat/jsx-spread-children
Add JSX spread children
2016-07-13 01:32:09 +01:00
Daniel Tschinder
15a391d305
Fix tests to not save expected output if we expect the test to fail 2016-07-11 13:35:50 +02:00
Daniel Tschinder
34a82f716e Fix the location of params, when flow and default value used (#68)
Fixes #67
2016-07-06 17:48:47 -04: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
d5f75cb2f0 flow: allow generic method with name get or set 2016-06-24 19:47:30 +03:00
Sebastian McKenzie
cf6e0d365e rename parser context types 2016-06-22 14:06:58 +01: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
78597290ec Merge pull request #23 from danez/fix-comments
Fix leading comments added from previous node
2016-06-22 12:44:12 +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
Daniel Tschinder
f11a82c96c Adjust cloning of nodes in import/export-specifiers and obj-destructuring (#24)
The cloning caused comments that where added to the original node to be persisted into
the cloned node.
Espree/Acorn does not have any cloning, that's why it is working there.
This change omits comments when cloning, as removing the cloning
causes tests in babel to fail.
2016-06-21 09:55:15 -04:00
Sebastian McKenzie
92d45c3f6c Merge pull request #16 from danez/enable-tests
Enable deactivated tests
2016-06-21 00:03:38 +01:00
Sebastian McKenzie
8977d8c75a Merge pull request #31 from eldereal/master
Allow use react elements after yield statement
2016-06-20 22:50:36 +01:00
calebmer
a25a4ffdc1 Add JSX spread children 2016-06-19 10:48:20 -04:00
Sebastian McKenzie
1c48c4c9db Merge pull request #25 from gabelevi/default
Support defaults in Flow's type parameter declarations
2016-05-17 01:00:49 +01:00
Yiyuan Bai
de56e12c68 Allow use react elements after yield statement 2016-05-12 18:41:41 +08:00
Henry Zhu
d4cd0bf7b7 Actually remove it.. 2016-05-02 22:44:50 -04:00
Henry Zhu
c81db57b03 Remove unused file
Ref f81c281fc4 (commitcomment-17331315)
2016-05-02 22:43:47 -04: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
4bfececdad Fix leading comments added from previous node
This fixes an issue that comments were added as leading comments
to expressions, which are not immediately folowing the comment.
This was also reported and fixed in espree, and is basically a port to
babylon. eslint/espree#256

this also fixes an issue in babel-eslint with certain rules babel/babel-eslint#289
2016-04-23 12:24:20 +02: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
Kevin Smith
f81c281fc4 Parse for-await statements when asyncGenerators plugin is active 2016-04-05 13:33:49 -04:00
Daniel Tschinder
bb6586d1e6 Enable deactivated tests, as it seems they work now 2016-04-04 18:22:10 +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
Shuhei Kagawa
29a6578658 parse parameter decorators 2016-03-25 14:04:33 +09:00
Sebastian McKenzie
64ff4c3561 first commit 2016-03-10 06:24:44 +00:00
Amjad Masad
6b498d7e5a Merge pull request #3323 from divmain/master
Source-map support for multiple input source files
2016-03-07 11:57:59 -08:00
Dale Bustad
bb4919500c Attach filename property to node.loc when provided. 2016-03-07 02:47:28 -08: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
Logan Smyth
40e5f505f4 Properly fail to parse >== and <== - fixes T2921 2016-02-13 10:08:05 -08:00
Henry Zhu
2e73358fcc Add class properties test with a generator method that results in a parse error 2016-02-11 13:03:36 -05:00
Logan Smyth
abd39d688e Add tests for class property ASI. 2016-02-06 23:01:38 -08:00
Logan Smyth
0c35bbfc07 Revert "babylon: throw parse error if class properties do not have a semicolon (fixes T6873)"
This reverts commit 976edfc06740e434d1d5b136e28996a77f909403.
2016-02-06 18:36:31 -08:00
Logan Smyth
d9ade8a63a Revert "babylon: fix error location for class properties with a missing semicolon"
This reverts commit f31099f383b52cf4fe1786188f6421529dea865b.
2016-02-06 18:36:22 -08: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
Henry Zhu
2f00b4c329 babylon: fix error location for class properties with a missing semicolon 2016-01-06 18:42:26 -05:00
Sebastian McKenzie
6c79639801 Merge pull request #3225 from hzoo/cp-semi
`babylon`: throw parse error if class properties do not have a semico…
2016-01-06 15:22:37 +00: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
Henry Zhu
e849c62144 babylon: throw parse error if class properties do not have a semicolon (fixes T6873) 2015-12-30 14:01:46 -05:00
Jesse McCarthy
c5a8d4c5b0 Add non-directive fixture.
(Failing.)
2015-12-28 11:04:33 -05: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