Skip to content

Commit

Permalink
Fix babel#321 by allowing question marks in type params (babel#338)
Browse files Browse the repository at this point in the history
* Fix babel#321 by allowing question marks in type params

* Require commas between params
  • Loading branch information
danez committed Feb 10, 2017
1 parent bc771bd commit 407c97c
Show file tree
Hide file tree
Showing 5 changed files with 625 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/flow.js
Expand Up @@ -569,7 +569,7 @@ pp.reinterpretTypeAsFunctionTypeParam = function (type) {

pp.flowParseFunctionTypeParams = function (params = []) {
const ret = { params, rest: null };
while (this.match(tt.name)) {
while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {
ret.params.push(this.flowParseFunctionTypeParam());
if (!this.match(tt.parenR)) {
this.expect(tt.comma);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/flow/regression/issue-321-failing/actual.js
@@ -0,0 +1 @@
const fn: ( Object, Object Object ) => void = ( o1, o2, ) => o1;
3 changes: 3 additions & 0 deletions test/fixtures/flow/regression/issue-321-failing/options.json
@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected , (1:27)"
}
2 changes: 2 additions & 0 deletions test/fixtures/flow/regression/issue-321/actual.js
@@ -0,0 +1,2 @@
const fn: ( Object, ?Object ) => void = ( o1, o2 ) => o1;
const fn: ( Object, ?Object, ) => void = ( o1, o2, ) => o1;

0 comments on commit 407c97c

Please sign in to comment.