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

Fixes #67
This commit is contained in:
Daniel Tschinder 2016-07-06 23:48:47 +02:00 committed by Henry Zhu
parent 83bf84f7cd
commit 34a82f716e
3 changed files with 251 additions and 1 deletions

View File

@ -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;

View File

@ -0,0 +1 @@
function g(a:number=1, e=1:number) {}

View File

@ -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": []
}
}