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

Commit eb1ad9b

Browse files
JamesHenrynzakas
authored andcommitted
Fix: Add loc and range data to generated VariableDeclarator node (#100)
1 parent 5dae849 commit eb1ad9b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/ast-converter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,10 @@ module.exports = function(ast, extra) {
18711871
var typeAliasDeclarator = {
18721872
type: "VariableDeclarator",
18731873
id: convertChild(node.name),
1874-
init: convertChild(node.type)
1874+
init: convertChild(node.type),
1875+
range: [node.name.getStart(), node.end]
18751876
};
1877+
typeAliasDeclarator.loc = getLocFor(typeAliasDeclarator.range[0], typeAliasDeclarator.range[1], ast);
18761878
// Process typeParameters
18771879
if (node.typeParameters && node.typeParameters.length) {
18781880
typeAliasDeclarator.typeParameters = convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters);

tests/fixtures/typescript/basics/type-alias-declaration.result.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ module.exports = {
2020
"kind": "type",
2121
"declarations": [
2222
{
23+
"loc": {
24+
"end": {
25+
"column": 37,
26+
"line": 1
27+
},
28+
"start": {
29+
"column": 5,
30+
"line": 1
31+
}
32+
},
33+
"range": [
34+
5,
35+
37
36+
],
2337
"type": "VariableDeclarator",
2438
"id": {
2539
"type": "Identifier",

0 commit comments

Comments
 (0)