Fix range for TypeScript optional parameter in arrow function (#9463)

This commit is contained in:
Brian Ng 2019-02-06 08:17:32 -06:00 committed by GitHub
parent e03e5ba01d
commit 07b0f22a3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 135 additions and 8 deletions

View File

@ -1849,7 +1849,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.finishNode(typeCastNode, "TSTypeCastExpression");
}
return node;
return this.finishNode(node, node.type);
}
parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {

View File

@ -1 +1,2 @@
(x?: number): any => x;
((k?) => k + 1)();

View File

@ -1,29 +1,29 @@
{
"type": "File",
"start": 0,
"end": 23,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
"line": 2,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
"line": 2,
"column": 18
}
},
"sourceType": "module",
@ -158,6 +158,132 @@
"name": "x"
}
}
},
{
"type": "ExpressionStatement",
"start": 24,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"expression": {
"type": "CallExpression",
"start": 24,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"callee": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 14
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "k"
},
"name": "k",
"optional": true
}
],
"body": {
"type": "BinaryExpression",
"start": 33,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 14
}
},
"left": {
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "k"
},
"name": "k"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 37,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 14
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
"extra": {
"parenthesized": true,
"parenStart": 24
}
},
"arguments": []
}
}
],
"directives": []