Fix range for TypeScript optional parameter in arrow function (#9463)
This commit is contained in:
parent
e03e5ba01d
commit
07b0f22a3f
@ -1849,7 +1849,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
return this.finishNode(typeCastNode, "TSTypeCastExpression");
|
return this.finishNode(typeCastNode, "TSTypeCastExpression");
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return this.finishNode(node, node.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {
|
parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
(x?: number): any => x;
|
(x?: number): any => x;
|
||||||
|
((k?) => k + 1)();
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 23,
|
"end": 42,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0
|
"column": 0
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 23
|
"column": 18
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 23,
|
"end": 42,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0
|
"column": 0
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 23
|
"column": 18
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
@ -158,6 +158,132 @@
|
|||||||
"name": "x"
|
"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": []
|
"directives": []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user