Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Fix the location of params, when flow and default value used #68

Merged
merged 1 commit into from
Jul 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser/lval.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
left.decorators = decorators;
}
this.parseAssignableListItemTypes(left);
elts.push(this.parseMaybeDefault(null, null, left));
elts.push(this.parseMaybeDefault(left.start, left.loc.start, left));
}
}
return elts;
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/flow/type-annotations/105/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function g(a:number=1, e=1:number) {}
249 changes: 249 additions & 0 deletions test/fixtures/flow/type-annotations/105/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"sourceType": "module",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "g"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 11,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 11,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 19
}
},
"name": "a",
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 19
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 13,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 19
}
}
}
}
},
"right": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "AssignmentPattern",
"start": 23,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 33
}
},
"left": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"name": "e"
},
"right": {
"type": "NumericLiteral",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"typeAnnotation": {
"type": "TypeAnnotation",
"start": 26,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 33
}
},
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 27,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 33
}
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 37
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}