This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
Incorrect location for typeAnnotation #314
Closed
Description
What version of typescript-eslint-parser
are you using?
8062515
What code were you trying to parse?
function x(o: { x: string }) {}
What did you expect to happen?
I expect that the Identifier
location to include its typeAnnotation location: 11 - 27.
We do a binary search in order to find the node nearest a comment and because the location is not inclusive, we don't go inside of the identifier and don't attach it correctly :( prettier/prettier#1946
What happened?
Right now, it gives me 11 - 12.
"params": [
{
"type": "Identifier",
"range": [
11, // <---------
12 // <---------
],
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
}
},
"name": "o",
"typeAnnotation": {
"type": "TypeAnnotation",
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 27
}
},
"range": [
14, // <---------
27 // <---------
],
"typeAnnotation": {
"type": "TSTypeLiteral",
"range": [
14,
27
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 27
}
},
"members": [
{
"type": "TSPropertySignature",
"range": [
16,
25
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 25
}
},
"optional": false,
"computed": false,
"key": {
"type": "Identifier",
"range": [
16,
17
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
}
},
"name": "x"
},
"typeAnnotation": {
"type": "TypeAnnotation",
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 25
}
},
"range": [
19,
25
],
"typeAnnotation": {
"type": "TSStringKeyword",
"range": [
19,
25
],
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 25
}
}
}
},
"initializer": null,
"accessibility": null,
"readonly": false,
"static": false,
"export": false
}
]
}