Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.

Commit c6b6609

Browse files
xixixaodanez
authored andcommitted
Fix location info on FunctionTypeParam nodes (#565)
1 parent eeba714 commit c6b6609

File tree

18 files changed

+64
-256
lines changed

18 files changed

+64
-256
lines changed

src/plugins/flow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ pp.flowParseFunctionTypeParam = function () {
575575
};
576576

577577
pp.reinterpretTypeAsFunctionTypeParam = function (type) {
578-
const node = this.startNodeAt(type.start, type.loc);
578+
const node = this.startNodeAt(type.start, type.loc.start);
579579
node.name = null;
580580
node.optional = false;
581581
node.typeAnnotation = type;
@@ -787,7 +787,7 @@ pp.flowParsePrefixType = function () {
787787
pp.flowParseAnonFunctionWithoutParens = function () {
788788
const param = this.flowParsePrefixType();
789789
if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) {
790-
const node = this.startNodeAt(param.start, param.loc);
790+
const node = this.startNodeAt(param.start, param.loc.start);
791791
node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
792792
node.rest = null;
793793
node.returnType = this.flowParseType();

test/fixtures/flow/anonymous-function-no-parens-types/good_01/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@
6666
"end": 23,
6767
"loc": {
6868
"start": {
69-
"start": {
70-
"line": 1,
71-
"column": 9
72-
},
73-
"end": {
74-
"line": 1,
75-
"column": 15
76-
}
69+
"line": 1,
70+
"column": 9
7771
},
7872
"end": {
7973
"line": 1,
@@ -87,14 +81,8 @@
8781
"end": 18,
8882
"loc": {
8983
"start": {
90-
"start": {
91-
"line": 1,
92-
"column": 9
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 15
97-
}
84+
"line": 1,
85+
"column": 9
9886
},
9987
"end": {
10088
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_02/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@
6666
"end": 30,
6767
"loc": {
6868
"start": {
69-
"start": {
70-
"line": 1,
71-
"column": 9
72-
},
73-
"end": {
74-
"line": 1,
75-
"column": 22
76-
}
69+
"line": 1,
70+
"column": 9
7771
},
7872
"end": {
7973
"line": 1,
@@ -87,14 +81,8 @@
8781
"end": 25,
8882
"loc": {
8983
"start": {
90-
"start": {
91-
"line": 1,
92-
"column": 9
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 22
97-
}
84+
"line": 1,
85+
"column": 9
9886
},
9987
"end": {
10088
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_05/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,8 @@
108108
"end": 27,
109109
"loc": {
110110
"start": {
111-
"start": {
112-
"line": 1,
113-
"column": 14
114-
},
115-
"end": {
116-
"line": 1,
117-
"column": 20
118-
}
111+
"line": 1,
112+
"column": 14
119113
},
120114
"end": {
121115
"line": 1,
@@ -129,14 +123,8 @@
129123
"end": 23,
130124
"loc": {
131125
"start": {
132-
"start": {
133-
"line": 1,
134-
"column": 14
135-
},
136-
"end": {
137-
"line": 1,
138-
"column": 20
139-
}
126+
"line": 1,
127+
"column": 14
140128
},
141129
"end": {
142130
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_06/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,8 @@
9696
"end": 35,
9797
"loc": {
9898
"start": {
99-
"start": {
100-
"line": 1,
101-
"column": 18
102-
},
103-
"end": {
104-
"line": 1,
105-
"column": 24
106-
}
99+
"line": 1,
100+
"column": 18
107101
},
108102
"end": {
109103
"line": 1,
@@ -117,14 +111,8 @@
117111
"end": 27,
118112
"loc": {
119113
"start": {
120-
"start": {
121-
"line": 1,
122-
"column": 18
123-
},
124-
"end": {
125-
"line": 1,
126-
"column": 24
127-
}
114+
"line": 1,
115+
"column": 18
128116
},
129117
"end": {
130118
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_07/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,8 @@
9696
"end": 35,
9797
"loc": {
9898
"start": {
99-
"start": {
100-
"line": 1,
101-
"column": 18
102-
},
103-
"end": {
104-
"line": 1,
105-
"column": 24
106-
}
99+
"line": 1,
100+
"column": 18
107101
},
108102
"end": {
109103
"line": 1,
@@ -117,14 +111,8 @@
117111
"end": 27,
118112
"loc": {
119113
"start": {
120-
"start": {
121-
"line": 1,
122-
"column": 18
123-
},
124-
"end": {
125-
"line": 1,
126-
"column": 24
127-
}
114+
"line": 1,
115+
"column": 18
128116
},
129117
"end": {
130118
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_08/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@
6666
"end": 27,
6767
"loc": {
6868
"start": {
69-
"start": {
70-
"line": 1,
71-
"column": 9
72-
},
73-
"end": {
74-
"line": 1,
75-
"column": 16
76-
}
69+
"line": 1,
70+
"column": 9
7771
},
7872
"end": {
7973
"line": 1,
@@ -87,14 +81,8 @@
8781
"end": 19,
8882
"loc": {
8983
"start": {
90-
"start": {
91-
"line": 1,
92-
"column": 9
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 16
97-
}
84+
"line": 1,
85+
"column": 9
9886
},
9987
"end": {
10088
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_09/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@
6666
"end": 28,
6767
"loc": {
6868
"start": {
69-
"start": {
70-
"line": 1,
71-
"column": 9
72-
},
73-
"end": {
74-
"line": 1,
75-
"column": 17
76-
}
69+
"line": 1,
70+
"column": 9
7771
},
7872
"end": {
7973
"line": 1,
@@ -87,14 +81,8 @@
8781
"end": 20,
8882
"loc": {
8983
"start": {
90-
"start": {
91-
"line": 1,
92-
"column": 9
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 17
97-
}
84+
"line": 1,
85+
"column": 9
9886
},
9987
"end": {
10088
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_10/expected.json

+6-30
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,8 @@
8181
"end": 27,
8282
"loc": {
8383
"start": {
84-
"start": {
85-
"start": {
86-
"line": 1,
87-
"column": 10
88-
},
89-
"end": {
90-
"line": 1,
91-
"column": 16
92-
}
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 27
97-
}
84+
"line": 1,
85+
"column": 10
9886
},
9987
"end": {
10088
"line": 1,
@@ -109,14 +97,8 @@
10997
"end": 27,
11098
"loc": {
11199
"start": {
112-
"start": {
113-
"line": 1,
114-
"column": 10
115-
},
116-
"end": {
117-
"line": 1,
118-
"column": 16
119-
}
100+
"line": 1,
101+
"column": 10
120102
},
121103
"end": {
122104
"line": 1,
@@ -130,14 +112,8 @@
130112
"end": 19,
131113
"loc": {
132114
"start": {
133-
"start": {
134-
"line": 1,
135-
"column": 10
136-
},
137-
"end": {
138-
"line": 1,
139-
"column": 16
140-
}
115+
"line": 1,
116+
"column": 10
141117
},
142118
"end": {
143119
"line": 1,

test/fixtures/flow/anonymous-function-no-parens-types/good_11/expected.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@
6666
"end": 35,
6767
"loc": {
6868
"start": {
69-
"start": {
70-
"line": 1,
71-
"column": 9
72-
},
73-
"end": {
74-
"line": 1,
75-
"column": 15
76-
}
69+
"line": 1,
70+
"column": 9
7771
},
7872
"end": {
7973
"line": 1,
@@ -87,14 +81,8 @@
8781
"end": 18,
8882
"loc": {
8983
"start": {
90-
"start": {
91-
"line": 1,
92-
"column": 9
93-
},
94-
"end": {
95-
"line": 1,
96-
"column": 15
97-
}
84+
"line": 1,
85+
"column": 9
9886
},
9987
"end": {
10088
"line": 1,

0 commit comments

Comments
 (0)