Skip to content

Commit ecb0366

Browse files
committed
Fix: Fix manual calculation of a type parameter's start
- use `name` field instead of `typeName` (fixes eslint#260)
1 parent 07a8e5c commit ecb0366

4 files changed

+8
-8
lines changed

Diff for: lib/ast-converter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ module.exports = function(ast, extra) {
632632
* Have to manually calculate the start of the range,
633633
* because TypeScript includes leading whitespace but Flow does not
634634
*/
635-
var typeParameterStart = (typeParameter.typeName && typeParameter.typeName.text)
636-
? typeParameter.end - typeParameter.typeName.text.length
635+
var typeParameterStart = (typeParameter.name && typeParameter.name.text)
636+
? typeParameter.name.end - typeParameter.name.text.length
637637
: typeParameter.pos;
638638

639639
var defaultParameter = typeParameter.default

Diff for: tests/fixtures/typescript/basics/export-default-class-with-multiple-generics.result.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ module.exports = {
7272
"line": 1
7373
},
7474
"start": {
75-
"column": 23,
75+
"column": 24,
7676
"line": 1
7777
}
7878
},
7979
"name": "U",
8080
"range": [
81-
23,
81+
24,
8282
25
8383
],
8484
"type": "TypeParameter",

Diff for: tests/fixtures/typescript/basics/export-named-class-with-multiple-generics.result.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ module.exports = {
8989
"line": 1
9090
},
9191
"start": {
92-
"column": 19,
92+
"column": 20,
9393
"line": 1
9494
}
9595
},
9696
"name": "U",
9797
"range": [
98-
19,
98+
20,
9999
21
100100
],
101101
"type": "TypeParameter",

Diff for: tests/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.result.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ module.exports = {
6565
line: 1
6666
},
6767
start: {
68-
column: 17,
68+
column: 28,
6969
line: 1
7070
}
7171
},
7272
name: "T",
73-
range: [17, 29],
73+
range: [28, 29],
7474
type: "TypeParameter"
7575
}],
7676
range: [16, 30],

0 commit comments

Comments
 (0)