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

Commit b243747

Browse files
committed
Breaking: Normalzie type parameters (fixes #197)
1 parent bfb1506 commit b243747

13 files changed

+1307
-927
lines changed

lib/ast-converter.js

+8
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,14 @@ module.exports = function(ast, extra) {
678678
}).forEach(function(key) {
679679
if (key === "type") {
680680
result.typeAnnotation = (node.type) ? convertTypeAnnotation(node.type) : null;
681+
} else if (key === "typeArguments") {
682+
result.typeParameters = (node.typeArguments)
683+
? convertTypeArgumentsToTypeParameters(node.typeArguments)
684+
: null;
685+
} else if (key === "typeParameters") {
686+
result.typeParameters = (node.typeParameters)
687+
? convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters)
688+
: null;
681689
} else {
682690
if (Array.isArray(node[key])) {
683691
result[key] = node[key].map(convertChild);

tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js

+51-17
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,59 @@ module.exports = {
159159
},
160160
"name": "Promise"
161161
},
162-
"typeArguments": [
163-
{
164-
"type": "TSStringKeyword",
165-
"range": [
166-
76,
167-
82
168-
],
169-
"loc": {
170-
"start": {
171-
"line": 2,
172-
"column": 37
162+
"typeParameters": {
163+
"loc": {
164+
"end": {
165+
"column": 44,
166+
"line": 2
167+
},
168+
"start": {
169+
"column": 36,
170+
"line": 2
171+
}
172+
},
173+
"params": [
174+
{
175+
"id": {
176+
"loc": {
177+
"end": {
178+
"column": 43,
179+
"line": 2
180+
},
181+
"start": {
182+
"column": 37,
183+
"line": 2
184+
}
185+
},
186+
"range": [
187+
76,
188+
82
189+
],
190+
"type": "TSStringKeyword"
173191
},
174-
"end": {
175-
"line": 2,
176-
"column": 43
177-
}
192+
"loc": {
193+
"end": {
194+
"column": 43,
195+
"line": 2
196+
},
197+
"start": {
198+
"column": 37,
199+
"line": 2
200+
}
201+
},
202+
"range": [
203+
76,
204+
82
205+
],
206+
"type": "GenericTypeAnnotation"
178207
}
179-
}
180-
]
208+
],
209+
"range": [
210+
75,
211+
83
212+
],
213+
"type": "TypeParameterInstantiation"
214+
}
181215
}
182216
},
183217
"params": []

tests/fixtures/typescript/basics/export-type-function-declaration.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module.exports = {
9999
"column": 27
100100
}
101101
},
102+
"typeParameters": null,
102103
"parameters": [
103104
{
104105
"type": "Identifier",

0 commit comments

Comments
 (0)