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

Commit 47fb44f

Browse files
committed
New Add class declaration type parameters to AST
1 parent 3ea409a commit 47fb44f

5 files changed

+185
-0
lines changed

lib/ast-converter.js

+1
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ module.exports = function(ast, extra) {
15061506
if (!lastClassToken || lastTypeParameter.pos > lastClassToken.pos) {
15071507
lastClassToken = ts.findNextToken(lastTypeParameter, ast);
15081508
}
1509+
result.typeParameters = convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters);
15091510
}
15101511

15111512
if (node.modifiers && node.modifiers.length) {

tests/fixtures/typescript/basics/export-default-class-with-generic.result.js

+37
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,43 @@ module.exports = {
3434
}
3535
},
3636
"id": null,
37+
"typeParameters": {
38+
"loc": {
39+
"end": {
40+
"column": 23,
41+
"line": 1
42+
},
43+
"start": {
44+
"column": 20,
45+
"line": 1
46+
}
47+
},
48+
"params": [
49+
{
50+
"loc": {
51+
"end": {
52+
"column": 22,
53+
"line": 1
54+
},
55+
"start": {
56+
"column": 21,
57+
"line": 1
58+
}
59+
},
60+
"name": "T",
61+
"range": [
62+
21,
63+
22
64+
],
65+
"type": "TypeParameter"
66+
}
67+
],
68+
"range": [
69+
20,
70+
23
71+
],
72+
"type": "TypeParameterDeclaration"
73+
},
3774
"body": {
3875
"type": "ClassBody",
3976
"body": [],

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

+55
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,61 @@ module.exports = {
3434
}
3535
},
3636
"id": null,
37+
"typeParameters": {
38+
"loc": {
39+
"end": {
40+
"column": 26,
41+
"line": 1
42+
},
43+
"start": {
44+
"column": 20,
45+
"line": 1
46+
}
47+
},
48+
"params": [
49+
{
50+
"loc": {
51+
"end": {
52+
"column": 22,
53+
"line": 1
54+
},
55+
"start": {
56+
"column": 21,
57+
"line": 1
58+
}
59+
},
60+
"name": "T",
61+
"range": [
62+
21,
63+
22
64+
],
65+
"type": "TypeParameter"
66+
},
67+
{
68+
"loc": {
69+
"end": {
70+
"column": 25,
71+
"line": 1
72+
},
73+
"start": {
74+
"column": 23,
75+
"line": 1
76+
}
77+
},
78+
"name": "U",
79+
"range": [
80+
23,
81+
25
82+
],
83+
"type": "TypeParameter"
84+
}
85+
],
86+
"range": [
87+
20,
88+
26
89+
],
90+
"type": "TypeParameterDeclaration"
91+
},
3792
"body": {
3893
"type": "ClassBody",
3994
"body": [],

tests/fixtures/typescript/basics/export-named-class-with-generic.result.js

+37
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,43 @@ module.exports = {
5151
},
5252
"name": "Foo"
5353
},
54+
"typeParameters": {
55+
"loc": {
56+
"end": {
57+
"column": 19,
58+
"line": 1
59+
},
60+
"start": {
61+
"column": 16,
62+
"line": 1
63+
}
64+
},
65+
"params": [
66+
{
67+
"loc": {
68+
"end": {
69+
"column": 18,
70+
"line": 1
71+
},
72+
"start": {
73+
"column": 17,
74+
"line": 1
75+
}
76+
},
77+
"name": "T",
78+
"range": [
79+
17,
80+
18
81+
],
82+
"type": "TypeParameter"
83+
}
84+
],
85+
"range": [
86+
16,
87+
19
88+
],
89+
"type": "TypeParameterDeclaration"
90+
},
5491
"body": {
5592
"type": "ClassBody",
5693
"body": [],

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

+55
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,61 @@ module.exports = {
5151
},
5252
"name": "Foo"
5353
},
54+
"typeParameters": {
55+
"loc": {
56+
"end": {
57+
"column": 22,
58+
"line": 1
59+
},
60+
"start": {
61+
"column": 16,
62+
"line": 1
63+
}
64+
},
65+
"params": [
66+
{
67+
"loc": {
68+
"end": {
69+
"column": 18,
70+
"line": 1
71+
},
72+
"start": {
73+
"column": 17,
74+
"line": 1
75+
}
76+
},
77+
"name": "T",
78+
"range": [
79+
17,
80+
18
81+
],
82+
"type": "TypeParameter"
83+
},
84+
{
85+
"loc": {
86+
"end": {
87+
"column": 21,
88+
"line": 1
89+
},
90+
"start": {
91+
"column": 19,
92+
"line": 1
93+
}
94+
},
95+
"name": "U",
96+
"range": [
97+
19,
98+
21
99+
],
100+
"type": "TypeParameter"
101+
}
102+
],
103+
"range": [
104+
16,
105+
22
106+
],
107+
"type": "TypeParameterDeclaration"
108+
},
54109
"body": {
55110
"type": "ClassBody",
56111
"body": [],

0 commit comments

Comments
 (0)