Fix TypeScript TypeParameterDeclaration location start values

This commit is contained in:
Brian Ng 2017-08-25 09:54:16 -05:00
parent 87b322cfc2
commit af2c974473
No known key found for this signature in database
GPG Key ID: 3F2380E1E1508CA9
17 changed files with 45 additions and 40 deletions

View File

@ -271,13 +271,20 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
tsTryParseTypeParameters(): ?N.TypeParameterDeclaration {
if (this.eatRelational("<")) {
if (this.isRelational("<")) {
return this.tsParseTypeParameters();
}
}
tsParseTypeParameters(): N.TypeParameterDeclaration {
tsParseTypeParameters() {
const node: N.TypeParameterDeclaration = this.startNode();
if (this.isRelational("<") || this.match(tt.jsxTagStart)) {
this.next();
} else {
this.unexpected();
}
node.params = this.tsParseBracketedList(
"TypeParametersOrArguments",
this.tsParseTypeParameter.bind(this),
@ -1150,7 +1157,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
startPos,
startLoc,
);
this.expectRelational("<");
node.typeParameters = this.tsParseTypeParameters();
// Don't use overloaded parseFunctionParams which would look for "<" again.
super.parseFunctionParams(node);
@ -1733,7 +1739,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let arrowExpression;
let typeParameters: N.TypeParameterDeclaration;
const state = this.state.clone();
this.next(); // skip the jsx start
try {
// This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`.
typeParameters = this.tsParseTypeParameters();

View File

@ -58,12 +58,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 7,
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 7
"column": 6
},
"end": {
"line": 1,

View File

@ -192,12 +192,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 62,
"start": 61,
"end": 64,
"loc": {
"start": {
"line": 2,
"column": 1
"column": 0
},
"end": {
"line": 2,

View File

@ -192,12 +192,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 1,
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 1
"column": 0
},
"end": {
"line": 1,

View File

@ -59,12 +59,12 @@
"id": null,
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 7,
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 7
"column": 6
},
"end": {
"line": 1,
@ -160,12 +160,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 24,
"start": 23,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 9
"column": 8
},
"end": {
"line": 2,

View File

@ -61,12 +61,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 8,
"start": 7,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 8
"column": 7
},
"end": {
"line": 1,

View File

@ -111,12 +111,12 @@
"kind": "method",
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 26,
"start": 25,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 8
"column": 7
},
"end": {
"line": 2,

View File

@ -306,12 +306,12 @@
"kind": "method",
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 85,
"start": 84,
"end": 87,
"loc": {
"start": {
"line": 5,
"column": 10
"column": 9
},
"end": {
"line": 5,

View File

@ -111,12 +111,12 @@
"kind": "method",
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 16,
"start": 15,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
"column": 5
},
"end": {
"line": 2,
@ -505,12 +505,12 @@
"kind": "method",
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 71,
"start": 70,
"end": 73,
"loc": {
"start": {
"line": 3,
"column": 22
"column": 21
},
"end": {
"line": 3,

View File

@ -64,12 +64,12 @@
"async": false,
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 11,
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 11
"column": 10
},
"end": {
"line": 1,

View File

@ -94,12 +94,12 @@
"async": false,
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 19,
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 19
"column": 18
},
"end": {
"line": 1,

View File

@ -131,12 +131,12 @@
"async": false,
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 47,
"start": 46,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 19
"column": 18
},
"end": {
"line": 2,

View File

@ -61,12 +61,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 12,
"start": 11,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 12
"column": 11
},
"end": {
"line": 1,

View File

@ -108,12 +108,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 20,
"start": 19,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 6
"column": 5
},
"end": {
"line": 2,

View File

@ -61,12 +61,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 7,
"start": 6,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 7
"column": 6
},
"end": {
"line": 1,

View File

@ -61,12 +61,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 7,
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 7
"column": 6
},
"end": {
"line": 1,

View File

@ -103,12 +103,12 @@
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 8,
"start": 7,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 8
"column": 7
},
"end": {
"line": 1,