Fix range on TypeScript index signature parameters (#9335)

This commit is contained in:
Brian Ng 2019-01-15 06:52:33 -06:00 committed by GitHub
parent e8038863c3
commit 34c9890f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 18 deletions

View File

@ -398,8 +398,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.expect(tt.bracketL); this.expect(tt.bracketL);
const id = this.parseIdentifier(); const id = this.parseIdentifier();
this.expect(tt.colon); id.typeAnnotation = this.tsParseTypeAnnotation();
id.typeAnnotation = this.tsParseTypeAnnotation(/* eatColon */ false); this.finishNode(id, "Identifier"); // set end position to end of type
this.expect(tt.bracketR); this.expect(tt.bracketR);
node.parameters = [id]; node.parameters = [id];

View File

@ -94,7 +94,7 @@
{ {
"type": "Identifier", "type": "Identifier",
"start": 23, "start": 23,
"end": 24, "end": 32,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
@ -102,19 +102,19 @@
}, },
"end": { "end": {
"line": 2, "line": 2,
"column": 6 "column": 14
}, },
"identifierName": "x" "identifierName": "x"
}, },
"name": "x", "name": "x",
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeAnnotation", "type": "TSTypeAnnotation",
"start": 26, "start": 24,
"end": 32, "end": 32,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
"column": 8 "column": 6
}, },
"end": { "end": {
"line": 2, "line": 2,

View File

@ -94,7 +94,7 @@
{ {
"type": "Identifier", "type": "Identifier",
"start": 15, "start": 15,
"end": 16, "end": 24,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
@ -102,19 +102,19 @@
}, },
"end": { "end": {
"line": 2, "line": 2,
"column": 6 "column": 14
}, },
"identifierName": "x" "identifierName": "x"
}, },
"name": "x", "name": "x",
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeAnnotation", "type": "TSTypeAnnotation",
"start": 18, "start": 16,
"end": 24, "end": 24,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
"column": 8 "column": 6
}, },
"end": { "end": {
"line": 2, "line": 2,
@ -189,7 +189,7 @@
{ {
"type": "Identifier", "type": "Identifier",
"start": 46, "start": 46,
"end": 47, "end": 55,
"loc": { "loc": {
"start": { "start": {
"line": 3, "line": 3,
@ -197,19 +197,19 @@
}, },
"end": { "end": {
"line": 3, "line": 3,
"column": 15 "column": 23
}, },
"identifierName": "x" "identifierName": "x"
}, },
"name": "x", "name": "x",
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeAnnotation", "type": "TSTypeAnnotation",
"start": 49, "start": 47,
"end": 55, "end": 55,
"loc": { "loc": {
"start": { "start": {
"line": 3, "line": 3,
"column": 17 "column": 15
}, },
"end": { "end": {
"line": 3, "line": 3,

View File

@ -93,7 +93,7 @@
{ {
"type": "Identifier", "type": "Identifier",
"start": 19, "start": 19,
"end": 20, "end": 28,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
@ -101,19 +101,19 @@
}, },
"end": { "end": {
"line": 2, "line": 2,
"column": 6 "column": 14
}, },
"identifierName": "s" "identifierName": "s"
}, },
"name": "s", "name": "s",
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeAnnotation", "type": "TSTypeAnnotation",
"start": 22, "start": 20,
"end": 28, "end": 28,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
"column": 8 "column": 6
}, },
"end": { "end": {
"line": 2, "line": 2,