diff --git a/lib/ast-converter.js b/lib/ast-converter.js index e612cf3..d98bc28 100644 --- a/lib/ast-converter.js +++ b/lib/ast-converter.js @@ -546,7 +546,10 @@ module.exports = function(ast, extra) { typeArgument.end ], loc: getLocFor(typeArgumentStart, typeArgument.end, ast), - id: convertChild(typeArgument.typeName || typeArgument) + id: convertChild(typeArgument.typeName || typeArgument), + typeParameters: (typeArgument.typeArguments) + ? convertTypeArgumentsToTypeParameters(typeArgument.typeArguments) + : null }; }) }; diff --git a/tests/fixtures/typescript/basics/class-with-implements-generic-multiple.result.js b/tests/fixtures/typescript/basics/class-with-implements-generic-multiple.result.js index 8669c88..aa81d2e 100644 --- a/tests/fixtures/typescript/basics/class-with-implements-generic-multiple.result.js +++ b/tests/fixtures/typescript/basics/class-with-implements-generic-multiple.result.js @@ -153,7 +153,8 @@ module.exports = { } }, "name": "S" - } + }, + "typeParameters": null }, { "type": "GenericTypeAnnotation", @@ -188,7 +189,8 @@ module.exports = { } }, "name": "T" - } + }, + "typeParameters": null } ] } @@ -398,4 +400,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/typescript/basics/class-with-implements-generic.result.js b/tests/fixtures/typescript/basics/class-with-implements-generic.result.js index 69b3e69..ac8fd32 100644 --- a/tests/fixtures/typescript/basics/class-with-implements-generic.result.js +++ b/tests/fixtures/typescript/basics/class-with-implements-generic.result.js @@ -153,7 +153,8 @@ module.exports = { } }, "name": "S" - } + }, + "typeParameters": null } ] } @@ -327,4 +328,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/typescript/basics/nested-type-arguments.result.js b/tests/fixtures/typescript/basics/nested-type-arguments.result.js new file mode 100644 index 0000000..2810f9d --- /dev/null +++ b/tests/fixtures/typescript/basics/nested-type-arguments.result.js @@ -0,0 +1,457 @@ +module.exports = { + "body": [ + { + "declarations": [ + { + "id": { + "loc": { + "end": { + "column": 15, + "line": 1 + }, + "start": { + "column": 4, + "line": 1 + } + }, + "name": "nestedArray", + "range": [ + 4, + 15 + ], + "type": "Identifier", + "typeAnnotation": { + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 17, + "line": 1 + } + }, + "range": [ + 17, + 44 + ], + "type": "TypeAnnotation", + "typeAnnotation": { + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 17, + "line": 1 + } + }, + "range": [ + 17, + 44 + ], + "type": "TSTypeReference", + "typeArguments": [ + { + "loc": { + "end": { + "column": 43, + "line": 1 + }, + "start": { + "column": 23, + "line": 1 + } + }, + "range": [ + 23, + 43 + ], + "type": "TSTypeReference", + "typeArguments": [ + { + "loc": { + "end": { + "column": 42, + "line": 1 + }, + "start": { + "column": 29, + "line": 1 + } + }, + "range": [ + 29, + 42 + ], + "type": "TSTypeReference", + "typeArguments": [ + { + "loc": { + "end": { + "column": 41, + "line": 1 + }, + "start": { + "column": 35, + "line": 1 + } + }, + "range": [ + 35, + 41 + ], + "type": "TSStringKeyword" + } + ], + "typeName": { + "loc": { + "end": { + "column": 34, + "line": 1 + }, + "start": { + "column": 29, + "line": 1 + } + }, + "name": "Array", + "range": [ + 29, + 34 + ], + "type": "Identifier" + } + } + ], + "typeName": { + "loc": { + "end": { + "column": 28, + "line": 1 + }, + "start": { + "column": 23, + "line": 1 + } + }, + "name": "Array", + "range": [ + 23, + 28 + ], + "type": "Identifier" + } + } + ], + "typeName": { + "loc": { + "end": { + "column": 22, + "line": 1 + }, + "start": { + "column": 17, + "line": 1 + } + }, + "name": "Array", + "range": [ + 17, + 22 + ], + "type": "Identifier" + } + } + } + }, + "init": null, + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 4, + "line": 1 + } + }, + "range": [ + 4, + 44 + ], + "type": "VariableDeclarator" + } + ], + "kind": "var", + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [ + 0, + 44 + ], + "type": "VariableDeclaration" + } + ], + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [ + 0, + 44 + ], + "sourceType": "script", + "tokens": [ + { + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [ + 0, + 3 + ], + "type": "Keyword", + "value": "var" + }, + { + "loc": { + "end": { + "column": 15, + "line": 1 + }, + "start": { + "column": 4, + "line": 1 + } + }, + "range": [ + 4, + 15 + ], + "type": "Identifier", + "value": "nestedArray" + }, + { + "loc": { + "end": { + "column": 16, + "line": 1 + }, + "start": { + "column": 15, + "line": 1 + } + }, + "range": [ + 15, + 16 + ], + "type": "Punctuator", + "value": ":" + }, + { + "loc": { + "end": { + "column": 22, + "line": 1 + }, + "start": { + "column": 17, + "line": 1 + } + }, + "range": [ + 17, + 22 + ], + "type": "Identifier", + "value": "Array" + }, + { + "loc": { + "end": { + "column": 23, + "line": 1 + }, + "start": { + "column": 22, + "line": 1 + } + }, + "range": [ + 22, + 23 + ], + "type": "Punctuator", + "value": "<" + }, + { + "loc": { + "end": { + "column": 28, + "line": 1 + }, + "start": { + "column": 23, + "line": 1 + } + }, + "range": [ + 23, + 28 + ], + "type": "Identifier", + "value": "Array" + }, + { + "loc": { + "end": { + "column": 29, + "line": 1 + }, + "start": { + "column": 28, + "line": 1 + } + }, + "range": [ + 28, + 29 + ], + "type": "Punctuator", + "value": "<" + }, + { + "loc": { + "end": { + "column": 34, + "line": 1 + }, + "start": { + "column": 29, + "line": 1 + } + }, + "range": [ + 29, + 34 + ], + "type": "Identifier", + "value": "Array" + }, + { + "loc": { + "end": { + "column": 35, + "line": 1 + }, + "start": { + "column": 34, + "line": 1 + } + }, + "range": [ + 34, + 35 + ], + "type": "Punctuator", + "value": "<" + }, + { + "loc": { + "end": { + "column": 41, + "line": 1 + }, + "start": { + "column": 35, + "line": 1 + } + }, + "range": [ + 35, + 41 + ], + "type": "Identifier", + "value": "string" + }, + { + "loc": { + "end": { + "column": 42, + "line": 1 + }, + "start": { + "column": 41, + "line": 1 + } + }, + "range": [ + 41, + 42 + ], + "type": "Punctuator", + "value": ">" + }, + { + "loc": { + "end": { + "column": 43, + "line": 1 + }, + "start": { + "column": 42, + "line": 1 + } + }, + "range": [ + 42, + 43 + ], + "type": "Punctuator", + "value": ">" + }, + { + "loc": { + "end": { + "column": 44, + "line": 1 + }, + "start": { + "column": 43, + "line": 1 + } + }, + "range": [ + 43, + 44 + ], + "type": "Punctuator", + "value": ">" + } + ], + "type": "Program" +}; diff --git a/tests/fixtures/typescript/basics/nested-type-arguments.src.ts b/tests/fixtures/typescript/basics/nested-type-arguments.src.ts new file mode 100644 index 0000000..1e9f542 --- /dev/null +++ b/tests/fixtures/typescript/basics/nested-type-arguments.src.ts @@ -0,0 +1 @@ +var nestedArray: Array>> \ No newline at end of file diff --git a/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js b/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js index e8077a5..3dfc525 100644 --- a/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js +++ b/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js @@ -82,6 +82,7 @@ module.exports = { ], "type": "Identifier" }, + "typeParameters": null, "loc": { "end": { "column": 5, @@ -188,6 +189,7 @@ module.exports = { ], "type": "TSNumberKeyword" }, + "typeParameters": null, "loc": { "end": { "column": 10, diff --git a/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js b/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js index 5110a6f..1d3d5bc 100644 --- a/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js +++ b/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js @@ -87,6 +87,7 @@ module.exports = { ], "type": "Identifier" }, + "typeParameters": null, "loc": { "end": { "column": 17,