From 32634f10b8c9bc4622762867d9d00e79ea1092fe Mon Sep 17 00:00:00 2001 From: Reyad Attiyat Date: Thu, 1 Jun 2017 22:22:57 -0500 Subject: [PATCH] Fix: Label readonly class properties (fixes #302) --- lib/convert.js | 1 + ...tract-class-with-abstract-method.result.js | 76 +- ...t-class-with-abstract-properties.result.js | 4 +- ...-with-abstract-readonly-property.result.js | 355 ++++++ ...ass-with-abstract-readonly-property.src.ts | 3 + ...tract-class-with-optional-method.result.js | 726 +++++------ ...ow-function-with-type-parameters.result.js | 4 +- ...nc-function-with-var-declaration.result.js | 2 +- ...ass-with-accessibility-modifiers.result.js | 77 +- ...with-export-parameter-properties.result.js | 2 +- ...lass-with-generic-method-default.result.js | 2 +- .../class-with-generic-method.result.js | 548 ++++----- ...with-implements-generic-multiple.result.js | 2 +- .../class-with-implements-generic.result.js | 2 +- ...-with-optional-computed-property.result.js | 3 +- .../class-with-optional-methods.result.js | 1006 +++++++-------- .../class-with-optional-properties.result.js | 781 ++++++------ ...with-optional-property-undefined.result.js | 4 +- ...ith-private-parameter-properties.result.js | 880 ++++++------- ...h-protected-parameter-properties.result.js | 810 ++++++------ ...with-public-parameter-properties.result.js | 792 ++++++------ ...th-readonly-parameter-properties.result.js | 520 ++++---- .../class-with-readonly-property.result.js | 319 +++++ .../class-with-readonly-property.src.ts | 3 + ...with-static-parameter-properties.result.js | 2 +- ...lass-with-type-parameter-default.result.js | 2 +- ...s-with-type-parameter-underscore.result.js | 2 +- .../class-with-type-parameter.result.js | 2 +- ...clare-class-with-optional-method.result.js | 516 ++++---- ...xport-default-class-with-generic.result.js | 50 +- ...ult-class-with-multiple-generics.result.js | 72 +- .../export-named-class-with-generic.result.js | 70 +- ...med-class-with-multiple-generics.result.js | 92 +- .../export-type-alias-declaration.result.js | 214 ++-- .../export-type-class-declaration.result.js | 214 ++-- ...export-type-function-declaration.result.js | 294 ++--- .../basics/function-with-await.result.js | 462 +++---- ...ct-type-with-optional-properties.result.js | 810 ++++++------ ...h-object-type-without-annotation.result.js | 2 +- ...pe-parameters-that-have-comments.result.js | 412 ++++--- ...-type-parameters-with-constraint.result.js | 876 ++++++------- .../function-with-type-parameters.result.js | 2 +- .../function-with-types-assignation.result.js | 781 ++++++------ ...nterface-with-all-property-types.result.js | 18 +- ...ure-with-parameter-accessibility.result.js | 6 +- .../basics/interface-with-jsdoc.result.js | 2 +- ...terface-with-optional-properties.result.js | 6 +- ...nterface-without-type-annotation.result.js | 2 +- .../basics/nested-type-arguments.result.js | 706 +++++------ .../non-null-assertion-operator.result.js | 6 +- ...-with-constrained-type-parameter.result.js | 710 +++++------ .../basics/type-alias-declaration.result.js | 72 +- ...-alias-object-without-annotation.result.js | 2 +- .../typescript/basics/type-guard.result.js | 1089 +++++++++-------- .../typescript/basics/typed-this.result.js | 2 +- .../basics/var-with-dotted-type.result.js | 2 +- ...ecorator-factory-instance-member.result.js | 2 + ...-decorator-factory-static-member.result.js | 2 + ...operty-decorator-instance-member.result.js | 2 + ...property-decorator-static-member.result.js | 2 + .../class-empty-extends-implements.result.js | 2 +- .../class-empty-extends.result.js | 2 +- .../class-extends-empty-implements.result.js | 2 +- .../interface-property-modifiers.result.js | 2 +- .../call-expression-type-arguments.result.js | 634 +++++----- .../new-expression-type-arguments.result.js | 498 ++++---- ...t-module-declaration-with-import.result.js | 494 ++++---- ...namespace-with-exported-function.result.js | 77 +- 68 files changed, 8445 insertions(+), 7694 deletions(-) create mode 100644 tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.result.js create mode 100644 tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts create mode 100644 tests/fixtures/typescript/basics/class-with-readonly-property.result.js create mode 100644 tests/fixtures/typescript/basics/class-with-readonly-property.src.ts diff --git a/lib/convert.js b/lib/convert.js index 124c424..632fc0f 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -676,6 +676,7 @@ module.exports = function convert(config) { computed: nodeUtils.isComputedProperty(node.name), static: nodeUtils.hasStaticModifierFlag(node), accessibility: nodeUtils.getTSNodeAccessibility(node), + readonly: nodeUtils.hasModifier(SyntaxKind.ReadonlyKeyword, node), decorators: convertDecorators(node.decorators), typeAnnotation: (node.type) ? convertTypeAnnotation(node.type) : null }); diff --git a/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js b/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js index ff0f61f..15450fe 100644 --- a/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js +++ b/tests/fixtures/typescript/basics/abstract-class-with-abstract-method.result.js @@ -160,58 +160,58 @@ module.exports = { "name": "Promise" }, "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 75, + 83 + ], "loc": { - "end": { - "column": 44, - "line": 2 - }, "start": { - "column": 36, - "line": 2 + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 44 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 43, - "line": 2 - }, - "start": { - "column": 37, - "line": 2 - } + "type": "GenericTypeAnnotation", + "range": [ + 76, + 82 + ], + "loc": { + "start": { + "line": 2, + "column": 37 }, + "end": { + "line": 2, + "column": 43 + } + }, + "id": { + "type": "TSStringKeyword", "range": [ 76, 82 ], - "type": "TSStringKeyword" - }, - "loc": { - "end": { - "column": 43, - "line": 2 - }, - "start": { - "column": 37, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 43 + } } }, - "range": [ - 76, - 82 - ], - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "range": [ - 75, - 83 - ], - "type": "TypeParameterInstantiation" + ] } } }, @@ -552,4 +552,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/abstract-class-with-abstract-properties.result.js b/tests/fixtures/typescript/basics/abstract-class-with-abstract-properties.result.js index d5b3cbc..f79e2ef 100644 --- a/tests/fixtures/typescript/basics/abstract-class-with-abstract-properties.result.js +++ b/tests/fixtures/typescript/basics/abstract-class-with-abstract-properties.result.js @@ -90,6 +90,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [], "typeAnnotation": null }, @@ -149,6 +150,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [], "typeAnnotation": null } @@ -410,4 +412,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.result.js b/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.result.js new file mode 100644 index 0000000..0c7160a --- /dev/null +++ b/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.result.js @@ -0,0 +1,355 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 65 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "TSAbstractClassDeclaration", + "range": [ + 0, + 65 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 15, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "Foo" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "TSAbstractClassProperty", + "range": [ + 23, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "key": { + "type": "Identifier", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "name": "foo" + }, + "value": { + "type": "Literal", + "range": [ + 54, + 62 + ], + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "value": "string", + "raw": "'string'" + }, + "computed": false, + "static": false, + "accessibility": "public", + "readonly": true, + "decorators": [], + "typeAnnotation": null + } + ], + "range": [ + 19, + 65 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "abstract", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "class", + "range": [ + 9, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 15, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + { + "type": "Keyword", + "value": "public", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "abstract", + "range": [ + 30, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "readonly", + "range": [ + 39, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 32 + } + } + }, + { + "type": "String", + "value": "'string'", + "range": [ + 54, + 62 + ], + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 41 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 42 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts b/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts new file mode 100644 index 0000000..8c28567 --- /dev/null +++ b/tests/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts @@ -0,0 +1,3 @@ +abstract class Foo { + public abstract readonly foo = 'string'; +} diff --git a/tests/fixtures/typescript/basics/abstract-class-with-optional-method.result.js b/tests/fixtures/typescript/basics/abstract-class-with-optional-method.result.js index 39abec7..96da715 100644 --- a/tests/fixtures/typescript/basics/abstract-class-with-optional-method.result.js +++ b/tests/fixtures/typescript/basics/abstract-class-with-optional-method.result.js @@ -1,556 +1,556 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 78 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { + "type": "ExportNamedDeclaration", "declaration": { + "type": "TSAbstractClassDeclaration", + "range": [ + 16, + 78 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 22, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "name": "AbstractSocket" + }, "body": { + "type": "ClassBody", "body": [ { - "accessibility": null, - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 16, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } + "type": "MethodDefinition", + "range": [ + 43, + 76 + ], + "loc": { + "start": { + "line": 2, + "column": 4 }, - "name": "createSocket", - "optional": true, + "end": { + "line": 2, + "column": 37 + } + }, + "key": { + "type": "Identifier", "range": [ 43, 55 ], - "type": "Identifier" - }, - "kind": "method", - "loc": { - "end": { - "column": 37, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } }, - "start": { - "column": 4, - "line": 2 - } + "name": "createSocket", + "optional": true }, - "range": [ - 43, - 76 - ], - "static": false, - "type": "MethodDefinition", "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, "async": false, "body": null, - "expression": false, - "generator": false, - "id": null, - "loc": { - "end": { - "column": 37, - "line": 2 - }, - "start": { - "column": 16, - "line": 2 - } - }, - "params": [], "range": [ 56, 76 ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 37 + } + }, "returnType": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 36, - "line": 2 - }, "start": { - "column": 21, - "line": 2 + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 36 } }, "range": [ 60, 75 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 36, - "line": 2 - }, - "start": { - "column": 21, - "line": 2 - } - }, + "type": "TSTypeReference", "range": [ 60, 75 ], - "type": "TSTypeReference", - "typeName": { - "loc": { - "end": { - "column": 28, - "line": 2 - }, - "start": { - "column": 21, - "line": 2 - } + "loc": { + "start": { + "line": 2, + "column": 21 }, - "name": "Promise", + "end": { + "line": 2, + "column": 36 + } + }, + "typeName": { + "type": "Identifier", "range": [ 60, 67 ], - "type": "Identifier" + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "name": "Promise" }, "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 67, + 75 + ], "loc": { - "end": { - "column": 36, - "line": 2 - }, "start": { - "column": 28, - "line": 2 + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 36 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 35, - "line": 2 - }, - "start": { - "column": 29, - "line": 2 - } + "type": "GenericTypeAnnotation", + "range": [ + 68, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 29 }, + "end": { + "line": 2, + "column": 35 + } + }, + "id": { + "type": "TSStringKeyword", "range": [ 68, 74 ], - "type": "TSStringKeyword" - }, - "loc": { - "end": { - "column": 35, - "line": 2 - }, - "start": { - "column": 29, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } } }, - "range": [ - 68, - 74 - ], - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "range": [ - 67, - 75 - ], - "type": "TypeParameterInstantiation" + ] } } }, - "type": "FunctionExpression" - } + "params": [] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 37, - "line": 1 - } - }, "range": [ 37, 78 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "column": 36, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 37 + }, + "end": { + "line": 3, + "column": 1 } - }, - "name": "AbstractSocket", - "range": [ - 22, - 36 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 16, - "line": 1 } }, - "range": [ - 16, - 78 - ], "superClass": null, - "type": "TSAbstractClassDeclaration" - }, - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } + "implements": [], + "decorators": [] }, "range": [ 0, 78 ], - "source": null, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "specifiers": [], - "type": "ExportNamedDeclaration" + "source": null } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 78 - ], "sourceType": "module", "tokens": [ { - "loc": { - "end": { - "column": 6, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "export", "range": [ 0, 6 ], - "type": "Keyword", - "value": "export" - }, - { "loc": { - "end": { - "column": 15, - "line": 1 - }, "start": { - "column": 7, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 } - }, + } + }, + { + "type": "Identifier", + "value": "abstract", "range": [ 7, 15 ], - "type": "Identifier", - "value": "abstract" - }, - { "loc": { - "end": { - "column": 21, - "line": 1 - }, "start": { - "column": 16, - "line": 1 + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 } - }, + } + }, + { + "type": "Keyword", + "value": "class", "range": [ 16, 21 ], - "type": "Keyword", - "value": "class" - }, - { "loc": { - "end": { - "column": 36, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 } - }, + } + }, + { + "type": "Identifier", + "value": "AbstractSocket", "range": [ 22, 36 ], - "type": "Identifier", - "value": "AbstractSocket" - }, - { "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 37, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 36 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 37, 38 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 16, - "line": 2 - }, "start": { - "column": 4, - "line": 2 + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 } - }, + } + }, + { + "type": "Identifier", + "value": "createSocket", "range": [ 43, 55 ], - "type": "Identifier", - "value": "createSocket" - }, - { "loc": { - "end": { - "column": 17, - "line": 2 - }, "start": { - "column": 16, - "line": 2 + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 55, 56 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 18, - "line": 2 - }, "start": { - "column": 17, - "line": 2 + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 56, 57 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 19, - "line": 2 - }, "start": { - "column": 18, - "line": 2 + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 57, 58 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 20, - "line": 2 - }, "start": { - "column": 19, - "line": 2 + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 58, 59 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 28, - "line": 2 - }, "start": { - "column": 21, - "line": 2 + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 } - }, + } + }, + { + "type": "Identifier", + "value": "Promise", "range": [ 60, 67 ], - "type": "Identifier", - "value": "Promise" - }, - { "loc": { - "end": { - "column": 29, - "line": 2 - }, "start": { - "column": 28, - "line": 2 + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 28 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 67, 68 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 35, - "line": 2 - }, "start": { - "column": 29, - "line": 2 + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 68, 74 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 36, - "line": 2 - }, "start": { - "column": 35, - "line": 2 + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 74, 75 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 37, - "line": 2 - }, "start": { - "column": 36, - "line": 2 + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 75, 76 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 37 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 77, 78 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/arrow-function-with-type-parameters.result.js b/tests/fixtures/typescript/basics/arrow-function-with-type-parameters.result.js index b000ecf..1780343 100644 --- a/tests/fixtures/typescript/basics/arrow-function-with-type-parameters.result.js +++ b/tests/fixtures/typescript/basics/arrow-function-with-type-parameters.result.js @@ -175,8 +175,8 @@ module.exports = { } ] }, - "expression": false, "async": false, + "expression": false, "returnType": { "type": "TypeAnnotation", "loc": { @@ -561,4 +561,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/async-function-with-var-declaration.result.js b/tests/fixtures/typescript/basics/async-function-with-var-declaration.result.js index 65bee37..6f08a71 100644 --- a/tests/fixtures/typescript/basics/async-function-with-var-declaration.result.js +++ b/tests/fixtures/typescript/basics/async-function-with-var-declaration.result.js @@ -695,4 +695,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-accessibility-modifiers.result.js b/tests/fixtures/typescript/basics/class-with-accessibility-modifiers.result.js index 45c030f..8ab949f 100644 --- a/tests/fixtures/typescript/basics/class-with-accessibility-modifiers.result.js +++ b/tests/fixtures/typescript/basics/class-with-accessibility-modifiers.result.js @@ -90,39 +90,40 @@ module.exports = { "computed": false, "static": false, "accessibility": "private", + "readonly": false, "decorators": [], "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 22, - "line": 2 - }, "start": { - "column": 16, - "line": 2 + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 } }, "range": [ 28, 34 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 22, - "line": 2 - }, - "start": { - "column": 16, - "line": 2 - } - }, + "type": "TSStringKeyword", "range": [ 28, 34 ], - "type": "TSStringKeyword" + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 + } + } } } }, @@ -164,42 +165,42 @@ module.exports = { "computed": false, "static": true, "accessibility": "public", + "readonly": false, "decorators": [], "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 28, - "line": 3 - }, "start": { - "column": 22, - "line": 3 + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 28 } }, "range": [ 58, 64 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 28, - "line": 3 - }, - "start": { - "column": 22, - "line": 3 - } - }, + "type": "TSNumberKeyword", "range": [ 58, 64 ], - "type": "TSNumberKeyword" + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 28 + } + } } } - }, { "type": "MethodDefinition", @@ -1355,4 +1356,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-export-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-export-parameter-properties.result.js index a97ced0..c531a48 100644 --- a/tests/fixtures/typescript/basics/class-with-export-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-export-parameter-properties.result.js @@ -464,4 +464,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-generic-method-default.result.js b/tests/fixtures/typescript/basics/class-with-generic-method-default.result.js index a93d926..dc79f2d 100644 --- a/tests/fixtures/typescript/basics/class-with-generic-method-default.result.js +++ b/tests/fixtures/typescript/basics/class-with-generic-method-default.result.js @@ -481,4 +481,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-generic-method.result.js b/tests/fixtures/typescript/basics/class-with-generic-method.result.js index fcdcbb2..82cb907 100644 --- a/tests/fixtures/typescript/basics/class-with-generic-method.result.js +++ b/tests/fixtures/typescript/basics/class-with-generic-method.result.js @@ -1,413 +1,413 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { + "type": "ClassDeclaration", + "range": [ + 0, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, "body": { + "type": "ClassBody", "body": [ { - "accessibility": null, - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 8, - "line": 2 - }, - "start": { - "column": 2, - "line": 2 - } + "type": "MethodDefinition", + "range": [ + 14, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 2 }, - "name": "getBar", + "end": { + "line": 2, + "column": 16 + } + }, + "key": { + "type": "Identifier", "range": [ 14, 20 ], - "type": "Identifier" - }, - "kind": "method", - "loc": { - "end": { - "column": 16, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } }, - "start": { - "column": 2, - "line": 2 - } + "name": "getBar" }, - "range": [ - 14, - 28 - ], - "static": false, - "type": "MethodDefinition", "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, "async": false, "body": { - "body": [], - "loc": { - "end": { - "column": 16, - "line": 2 - }, - "start": { - "column": 14, - "line": 2 - } - }, + "type": "BlockStatement", "range": [ 26, 28 ], - "type": "BlockStatement" - }, - "expression": false, - "generator": false, - "id": null, - "loc": { - "end": { - "column": 16, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } }, - "start": { - "column": 8, - "line": 2 - } + "body": [] }, - "params": [], "range": [ 23, 28 ], - "type": "FunctionExpression", + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "params": [], "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 20, + 23 + ], "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 8, - "line": 2 + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 } }, "params": [ { - "constraint": null, + "type": "TypeParameter", + "range": [ + 21, + 22 + ], "loc": { - "end": { - "column": 10, - "line": 2 - }, "start": { - "column": 9, - "line": 2 + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 } }, "name": "T", - "range": [ - 21, - 22 - ], - "type": "TypeParameter" + "constraint": null } - ], - "range": [ - 20, - 23 - ], - "type": "TypeParameterDeclaration" + ] } - } + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 10, - "line": 1 - } - }, "range": [ 10, 30 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 } - }, - "name": "Foo", - "range": [ - 6, - 9 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 } }, - "range": [ - 0, - 30 - ], "superClass": null, - "type": "ClassDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 + "implements": [], + "decorators": [] } - }, - "range": [ - 0, - 30 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "class", "range": [ 0, 5 ], - "type": "Keyword", - "value": "class" - }, - { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, + } + }, + { + "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], - "type": "Identifier", - "value": "Foo" - }, - { "loc": { - "end": { - "column": 11, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 8, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "getBar", "range": [ 14, 20 ], - "type": "Identifier", - "value": "getBar" - }, - { "loc": { - "end": { - "column": 9, - "line": 2 - }, "start": { - "column": 8, - "line": 2 + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 20, 21 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 10, - "line": 2 - }, "start": { - "column": 9, - "line": 2 + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "T", "range": [ 21, 22 ], - "type": "Identifier", - "value": "T" - }, - { "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 10, - "line": 2 + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 22, 23 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 12, - "line": 2 - }, "start": { - "column": 11, - "line": 2 + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 23, 24 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 13, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 24, 25 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 15, - "line": 2 - }, "start": { - "column": 14, - "line": 2 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 26, 27 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 16, - "line": 2 - }, "start": { - "column": 15, - "line": 2 + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 27, 28 ], - "type": "Punctuator", - "value": "}" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 29, 30 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file 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 aa81d2e..af2a472 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 @@ -400,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 ac8fd32..2a5f27c 100644 --- a/tests/fixtures/typescript/basics/class-with-implements-generic.result.js +++ b/tests/fixtures/typescript/basics/class-with-implements-generic.result.js @@ -328,4 +328,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-optional-computed-property.result.js b/tests/fixtures/typescript/basics/class-with-optional-computed-property.result.js index a679aef..2c07fbe 100644 --- a/tests/fixtures/typescript/basics/class-with-optional-computed-property.result.js +++ b/tests/fixtures/typescript/basics/class-with-optional-computed-property.result.js @@ -108,6 +108,7 @@ module.exports = { "computed": true, "static": false, "accessibility": "private", + "readonly": false, "decorators": [], "typeAnnotation": null, "optional": true @@ -352,4 +353,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-optional-methods.result.js b/tests/fixtures/typescript/basics/class-with-optional-methods.result.js index 13b27ea..01de572 100644 --- a/tests/fixtures/typescript/basics/class-with-optional-methods.result.js +++ b/tests/fixtures/typescript/basics/class-with-optional-methods.result.js @@ -1,771 +1,771 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 67 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, "body": [ { + "type": "ClassDeclaration", + "range": [ + 0, + 67 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, "body": { + "type": "ClassBody", "body": [ { - "accessibility": null, - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 5, - "line": 2 - }, - "start": { - "column": 2, - "line": 2 - } + "type": "MethodDefinition", + "range": [ + 14, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 2 }, - "name": "foo", - "optional": true, + "end": { + "line": 2, + "column": 9 + } + }, + "key": { + "type": "Identifier", "range": [ 14, 17 ], - "type": "Identifier" - }, - "kind": "method", - "loc": { - "end": { - "column": 9, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + } }, - "start": { - "column": 2, - "line": 2 - } + "name": "foo", + "optional": true }, - "range": [ - 14, - 21 - ], - "static": false, - "type": "MethodDefinition", "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, "async": false, "body": null, - "expression": false, - "generator": false, - "id": null, - "loc": { - "end": { - "column": 9, - "line": 2 - }, - "start": { - "column": 5, - "line": 2 - } - }, - "params": [], "range": [ 18, 21 ], - "type": "FunctionExpression" - } - }, - { - "accessibility": null, - "computed": false, - "decorators": [], - "key": { "loc": { - "end": { - "column": 5, - "line": 3 - }, "start": { - "column": 2, - "line": 3 + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 9 } }, - "name": "bar", - "optional": true, - "range": [ - 24, - 27 - ], - "type": "Identifier" + "params": [] }, + "computed": false, + "static": false, "kind": "method", - "loc": { - "end": { - "column": 17, - "line": 3 - }, - "start": { - "column": 2, - "line": 3 - } - }, + "accessibility": null, + "decorators": [] + }, + { + "type": "MethodDefinition", "range": [ 24, 39 ], - "static": false, - "type": "MethodDefinition", - "value": { - "async": false, - "body": null, - "expression": false, - "generator": false, - "id": null, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "key": { + "type": "Identifier", + "range": [ + 24, + 27 + ], "loc": { - "end": { - "column": 17, - "line": 3 - }, "start": { - "column": 5, - "line": 3 + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 } }, - "params": [], + "name": "bar", + "optional": true + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": null, "range": [ 28, 39 ], + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 17 + } + }, "returnType": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 16, - "line": 3 - }, "start": { - "column": 10, - "line": 3 + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 16 } }, "range": [ 32, 38 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 16, - "line": 3 - }, - "start": { - "column": 10, - "line": 3 - } - }, + "type": "TSStringKeyword", "range": [ 32, 38 ], - "type": "TSStringKeyword" + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 16 + } + } } }, - "type": "FunctionExpression" - } + "params": [] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] }, { - "accessibility": "private", - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 13, - "line": 4 - }, - "start": { - "column": 10, - "line": 4 - } + "type": "MethodDefinition", + "range": [ + 42, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 2 }, - "name": "baz", - "optional": true, + "end": { + "line": 4, + "column": 25 + } + }, + "key": { + "type": "Identifier", "range": [ 50, 53 ], - "type": "Identifier" - }, - "kind": "method", - "loc": { - "end": { - "column": 25, - "line": 4 + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 13 + } }, - "start": { - "column": 2, - "line": 4 - } + "name": "baz", + "optional": true }, - "range": [ - 42, - 65 - ], - "static": false, - "type": "MethodDefinition", "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, "async": false, "body": null, - "expression": false, - "generator": false, - "id": null, - "loc": { - "end": { - "column": 25, - "line": 4 - }, - "start": { - "column": 13, - "line": 4 - } - }, - "params": [], "range": [ 54, 65 ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 25 + } + }, "returnType": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 24, - "line": 4 - }, "start": { - "column": 18, - "line": 4 + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 24 } }, "range": [ 58, 64 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 24, - "line": 4 - }, - "start": { - "column": 18, - "line": 4 - } - }, + "type": "TSStringKeyword", "range": [ 58, 64 ], - "type": "TSStringKeyword" + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 24 + } + } } }, - "type": "FunctionExpression" - } + "params": [] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": "private", + "decorators": [] } ], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 10, - "line": 1 - } - }, "range": [ 10, 67 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 } - }, - "name": "Foo", - "range": [ - 6, - 9 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 0, - "line": 1 } }, - "range": [ - 0, - 67 - ], "superClass": null, - "type": "ClassDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 0, - "line": 1 + "implements": [], + "decorators": [] } - }, - "range": [ - 0, - 67 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "class", "range": [ 0, 5 ], - "type": "Keyword", - "value": "class" - }, - { - "loc": { - "end": { - "column": 9, - "line": 1 - }, + "loc": { "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, + } + }, + { + "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], - "type": "Identifier", - "value": "Foo" - }, - { "loc": { - "end": { - "column": 11, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 5, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "foo", "range": [ 14, 17 ], - "type": "Identifier", - "value": "foo" - }, - { "loc": { - "end": { - "column": 6, - "line": 2 - }, "start": { - "column": 5, - "line": 2 + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 17, 18 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 7, - "line": 2 - }, "start": { - "column": 6, - "line": 2 + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 18, 19 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 8, - "line": 2 - }, "start": { - "column": 7, - "line": 2 + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 19, 20 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 9, - "line": 2 - }, "start": { - "column": 8, - "line": 2 + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 20, 21 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 5, - "line": 3 - }, "start": { - "column": 2, - "line": 3 + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "bar", "range": [ 24, 27 ], - "type": "Identifier", - "value": "bar" - }, - { "loc": { - "end": { - "column": 6, - "line": 3 - }, "start": { - "column": 5, - "line": 3 + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 27, 28 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 7, - "line": 3 - }, "start": { - "column": 6, - "line": 3 + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 28, 29 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 8, - "line": 3 - }, "start": { - "column": 7, - "line": 3 + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 29, 30 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 9, - "line": 3 - }, "start": { - "column": 8, - "line": 3 + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 30, 31 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 16, - "line": 3 - }, "start": { - "column": 10, - "line": 3 + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 32, 38 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 17, - "line": 3 - }, "start": { - "column": 16, - "line": 3 + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 16 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 38, 39 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 9, - "line": 4 - }, "start": { - "column": 2, - "line": 4 + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 } - }, + } + }, + { + "type": "Keyword", + "value": "private", "range": [ 42, 49 ], - "type": "Keyword", - "value": "private" - }, - { "loc": { - "end": { - "column": 13, - "line": 4 - }, "start": { - "column": 10, - "line": 4 + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "baz", "range": [ 50, 53 ], - "type": "Identifier", - "value": "baz" - }, - { "loc": { - "end": { - "column": 14, - "line": 4 - }, "start": { - "column": 13, - "line": 4 + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 53, 54 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 15, - "line": 4 - }, "start": { - "column": 14, - "line": 4 + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 54, 55 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 16, - "line": 4 - }, "start": { - "column": 15, - "line": 4 + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 55, 56 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 17, - "line": 4 - }, "start": { - "column": 16, - "line": 4 + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 16 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 56, 57 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 24, - "line": 4 - }, "start": { - "column": 18, - "line": 4 + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 17 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 58, 64 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 25, - "line": 4 - }, "start": { - "column": 24, - "line": 4 + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 24 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 64, 65 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 5 - }, "start": { - "column": 0, - "line": 5 + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 66, 67 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-optional-properties.result.js b/tests/fixtures/typescript/basics/class-with-optional-properties.result.js index 54b3544..f219614 100644 --- a/tests/fixtures/typescript/basics/class-with-optional-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-optional-properties.result.js @@ -1,595 +1,598 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 63 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, "body": [ { + "type": "ClassDeclaration", + "range": [ + 0, + 63 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, "body": { + "type": "ClassBody", "body": [ { - "accessibility": null, - "computed": false, - "decorators": [], + "type": "ClassProperty", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], "loc": { - "end": { - "column": 5, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 } }, "name": "foo", - "optional": true, - "range": [ - 14, - 17 - ], - "type": "Identifier" + "optional": true }, + "value": null, + "computed": false, + "static": false, + "accessibility": null, + "readonly": false, + "decorators": [], + "typeAnnotation": null + }, + { + "type": "ClassProperty", + "range": [ + 22, + 36 + ], "loc": { - "end": { - "column": 7, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 16 } }, - "range": [ - 14, - 19 - ], - "static": false, - "type": "ClassProperty", - "typeAnnotation": null, - "value": null - }, - { - "accessibility": null, - "computed": false, - "decorators": [], "key": { - "loc": { - "end": { - "column": 5, - "line": 3 - }, - "start": { - "column": 2, - "line": 3 - } - }, - "name": "bar", - "optional": true, + "type": "Identifier", "range": [ 22, 25 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 16, - "line": 3 + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } }, - "start": { - "column": 2, - "line": 3 - } + "name": "bar", + "optional": true }, - "range": [ - 22, - 36 - ], + "value": null, + "computed": false, "static": false, - "type": "ClassProperty", + "accessibility": null, + "readonly": false, + "decorators": [], "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 15, - "line": 3 - }, "start": { - "column": 9, - "line": 3 + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 15 } }, "range": [ 29, 35 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 15, - "line": 3 - }, - "start": { - "column": 9, - "line": 3 - } - }, + "type": "TSStringKeyword", "range": [ 29, 35 ], - "type": "TSStringKeyword" + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 15 + } + } } - }, - "value": null + } }, { - "accessibility": "private", - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 13, - "line": 4 - }, - "start": { - "column": 10, - "line": 4 - } + "type": "ClassProperty", + "range": [ + 39, + 61 + ], + "loc": { + "start": { + "line": 4, + "column": 2 }, - "name": "baz", - "optional": true, + "end": { + "line": 4, + "column": 24 + } + }, + "key": { + "type": "Identifier", "range": [ 47, 50 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 24, - "line": 4 + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 13 + } }, - "start": { - "column": 2, - "line": 4 - } + "name": "baz", + "optional": true }, - "range": [ - 39, - 61 - ], + "value": null, + "computed": false, "static": false, - "type": "ClassProperty", + "accessibility": "private", + "readonly": false, + "decorators": [], "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 23, - "line": 4 - }, "start": { - "column": 17, - "line": 4 + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 23 } }, "range": [ 54, 60 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 23, - "line": 4 - }, - "start": { - "column": 17, - "line": 4 - } - }, + "type": "TSStringKeyword", "range": [ 54, 60 ], - "type": "TSStringKeyword" + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 23 + } + } } - }, - "value": null + } } ], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 10, - "line": 1 - } - }, "range": [ 10, 63 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 } - }, - "name": "Foo", - "range": [ - 6, - 9 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 0, - "line": 1 } }, - "range": [ - 0, - 63 - ], "superClass": null, - "type": "ClassDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 5 - }, - "start": { - "column": 0, - "line": 1 + "implements": [], + "decorators": [] } - }, - "range": [ - 0, - 63 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "class", "range": [ 0, 5 ], - "type": "Keyword", - "value": "class" - }, - { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, + } + }, + { + "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], - "type": "Identifier", - "value": "Foo" - }, - { "loc": { - "end": { - "column": 11, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 5, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "foo", "range": [ 14, 17 ], - "type": "Identifier", - "value": "foo" - }, - { "loc": { - "end": { - "column": 6, - "line": 2 - }, "start": { - "column": 5, - "line": 2 + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 17, 18 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 7, - "line": 2 - }, "start": { - "column": 6, - "line": 2 + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 18, 19 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 5, - "line": 3 - }, "start": { - "column": 2, - "line": 3 + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 } - }, + } + }, + { + "type": "Identifier", + "value": "bar", "range": [ 22, 25 ], - "type": "Identifier", - "value": "bar" - }, - { "loc": { - "end": { - "column": 6, - "line": 3 - }, "start": { - "column": 5, - "line": 3 + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 25, 26 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 8, - "line": 3 - }, "start": { - "column": 7, - "line": 3 + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 27, 28 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 15, - "line": 3 - }, "start": { - "column": 9, - "line": 3 + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 29, 35 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 16, - "line": 3 - }, "start": { - "column": 15, - "line": 3 + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 35, 36 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 9, - "line": 4 - }, "start": { - "column": 2, - "line": 4 + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 } - }, + } + }, + { + "type": "Keyword", + "value": "private", "range": [ 39, 46 ], - "type": "Keyword", - "value": "private" - }, - { "loc": { - "end": { - "column": 13, - "line": 4 - }, "start": { - "column": 10, - "line": 4 + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "baz", "range": [ 47, 50 ], - "type": "Identifier", - "value": "baz" - }, - { "loc": { - "end": { - "column": 14, - "line": 4 - }, "start": { - "column": 13, - "line": 4 + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 50, 51 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 16, - "line": 4 - }, "start": { - "column": 15, - "line": 4 + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 52, 53 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 23, - "line": 4 - }, "start": { - "column": 17, - "line": 4 + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 16 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 54, 60 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 24, - "line": 4 - }, "start": { - "column": 23, - "line": 4 + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 23 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 60, 61 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 5 - }, "start": { - "column": 0, - "line": 5 + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 62, 63 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-optional-property-undefined.result.js b/tests/fixtures/typescript/basics/class-with-optional-property-undefined.result.js index efbe484..029d97d 100644 --- a/tests/fixtures/typescript/basics/class-with-optional-property-undefined.result.js +++ b/tests/fixtures/typescript/basics/class-with-optional-property-undefined.result.js @@ -108,6 +108,7 @@ module.exports = { "computed": false, "static": false, "accessibility": "private", + "readonly": false, "decorators": [], "typeAnnotation": null } @@ -315,5 +316,4 @@ module.exports = { } } ] -}; - +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-private-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-private-parameter-properties.result.js index 15ae8d8..6239f46 100644 --- a/tests/fixtures/typescript/basics/class-with-private-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-private-parameter-properties.result.js @@ -5,94 +5,89 @@ module.exports = { 203 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } }, "body": [ { + "type": "ClassDeclaration", + "range": [ + 0, + 203 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, "body": { + "type": "ClassBody", "body": [ { "type": "MethodDefinition", - "kind": "constructor", "range": [ 14, 201 ], "loc": { - "end": { - "line": 5, - "column": 59 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 5, + "column": 59 } }, - "accessibility": null, - "computed": false, "key": { "type": "Identifier", + "name": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 - } - }, - "name": "constructor" - }, - "static": false, - "value": { - "type": "FunctionExpression", - "range": [ - 25, - 201 - ], - "loc": { - "end": { - "line": 5, - "column": 59 }, - "start": { + "end": { "line": 2, "column": 13 } - }, - "async": false, - "body": { - "type": "BlockStatement", - "range": [ - 199, - 201 - ], - "loc": { - "end": { - "line": 5, - "column": 59 - }, - "start": { - "line": 5, - "column": 57 - } - }, - "body": [] - }, - "expression": false, - "generator": false, + } + }, + "value": { + "type": "FunctionExpression", "id": null, "params": [ { @@ -102,20 +97,19 @@ module.exports = { 51 ], "loc": { - "end": { - "line": 2, - "column": 39 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 39 } }, - "decorators": [], "accessibility": "private", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "Identifier", "range": [ @@ -123,32 +117,32 @@ module.exports = { 43 ], "loc": { - "end": { - "line": 2, - "column": 31 - }, "start": { "line": 2, "column": 22 + }, + "end": { + "line": 2, + "column": 31 } }, "name": "firstName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 45, - 51 - ], "loc": { - "end": { - "line": 2, - "column": 39 - }, "start": { "line": 2, "column": 33 + }, + "end": { + "line": 2, + "column": 39 } }, + "range": [ + 45, + 51 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -156,18 +150,19 @@ module.exports = { 51 ], "loc": { - "end": { - "line": 2, - "column": 39 - }, "start": { "line": 2, "column": 33 + }, + "end": { + "line": 2, + "column": 39 } } } } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -176,20 +171,19 @@ module.exports = { 100 ], "loc": { - "end": { - "line": 3, - "column": 47 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 47 } }, - "decorators": [], "accessibility": "private", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "Identifier", "range": [ @@ -197,32 +191,32 @@ module.exports = { 92 ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 31 + }, + "end": { + "line": 3, + "column": 39 } }, "name": "lastName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 94, - 100 - ], "loc": { - "end": { - "line": 3, - "column": 47 - }, "start": { "line": 3, "column": 41 + }, + "end": { + "line": 3, + "column": 47 } }, + "range": [ + 94, + 100 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -230,18 +224,19 @@ module.exports = { 100 ], "loc": { - "end": { - "line": 3, - "column": 47 - }, "start": { "line": 3, "column": 41 + }, + "end": { + "line": 3, + "column": 47 } } } } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -250,21 +245,35 @@ module.exports = { 140 ], "loc": { - "end": { - "line": 4, - "column": 38 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 38 } }, - "decorators": [], "accessibility": "private", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { + "type": "AssignmentPattern", + "range": [ + 116, + 140 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 38 + } + }, "left": { "type": "Identifier", "range": [ @@ -272,32 +281,32 @@ module.exports = { 127 ], "loc": { - "end": { - "line": 4, - "column": 25 - }, "start": { "line": 4, "column": 22 + }, + "end": { + "line": 4, + "column": 25 } }, "name": "age", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 129, - 135 - ], "loc": { - "end": { - "line": 4, - "column": 33 - }, "start": { "line": 4, "column": 27 + }, + "end": { + "line": 4, + "column": 33 } }, + "range": [ + 129, + 135 + ], "typeAnnotation": { "type": "TSNumberKeyword", "range": [ @@ -305,53 +314,39 @@ module.exports = { 135 ], "loc": { - "end": { - "line": 4, - "column": 33 - }, "start": { "line": 4, "column": 27 + }, + "end": { + "line": 4, + "column": 33 } } } } }, - "type": "AssignmentPattern", - "range": [ - 116, - 140 - ], - "loc": { - "end": { - "line": 4, - "column": 38 - }, - "start": { - "line": 4, - "column": 14 - } - }, "right": { + "type": "Literal", + "range": [ + 138, + 140 + ], "loc": { - "end": { - "line": 4, - "column": 38 - }, "start": { "line": 4, "column": 36 + }, + "end": { + "line": 4, + "column": 38 } }, - "range": [ - 138, - 140 - ], - "raw": "30", - "type": "Literal", - "value": 30 + "value": 30, + "raw": "30" } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -360,21 +355,35 @@ module.exports = { 197 ], "loc": { - "end": { - "line": 5, - "column": 55 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 55 } }, - "decorators": [], "accessibility": "private", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { + "type": "AssignmentPattern", + "range": [ + 156, + 197 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 55 + } + }, "left": { "type": "Identifier", "range": [ @@ -382,32 +391,32 @@ module.exports = { 180 ], "loc": { - "end": { - "line": 5, - "column": 38 - }, "start": { "line": 5, "column": 31 + }, + "end": { + "line": 5, + "column": 38 } }, "name": "student", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 182, - 189 - ], "loc": { - "end": { - "line": 5, - "column": 47 - }, "start": { "line": 5, "column": 40 + }, + "end": { + "line": 5, + "column": 47 } }, + "range": [ + 182, + 189 + ], "typeAnnotation": { "type": "TSBooleanKeyword", "range": [ @@ -415,33 +424,18 @@ module.exports = { 189 ], "loc": { - "end": { - "line": 5, - "column": 47 - }, "start": { "line": 5, "column": 40 + }, + "end": { + "line": 5, + "column": 47 } } } } }, - "type": "AssignmentPattern", - "range": [ - 156, - 197 - ], - "loc": { - "end": { - "line": 5, - "column": 55 - }, - "start": { - "line": 5, - "column": 14 - } - }, "right": { "type": "Literal", "range": [ @@ -449,691 +443,697 @@ module.exports = { 197 ], "loc": { - "end": { - "line": 5, - "column": 55 - }, "start": { "line": 5, "column": 50 + }, + "end": { + "line": 5, + "column": 55 } }, - "raw": "false", - "value": false + "value": false, + "raw": "false" } + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 199, + 201 + ], + "loc": { + "start": { + "line": 5, + "column": 57 + }, + "end": { + "line": 5, + "column": 59 } + }, + "body": [] + }, + "range": [ + 25, + 201 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 5, + "column": 59 } - ] - } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" } ], - "loc": { - "end": { - "line": 6, - "column": 1 - }, - "start": { - "line": 1, - "column": 10 - } - }, "range": [ 10, 203 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, - "column": 6 + "column": 10 + }, + "end": { + "line": 6, + "column": 1 } - }, - "name": "Foo", - "range": [ - 6, - 9 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "line": 6, - "column": 1 - }, - "start": { - "line": 1, - "column": 0 } }, - "range": [ - 0, - 203 - ], "superClass": null, - "type": "ClassDeclaration" + "implements": [], + "decorators": [] } ], "sourceType": "script", "tokens": [ { "type": "Keyword", + "value": "class", "range": [ 0, 5 ], "loc": { - "end": { - "line": 1, - "column": 5 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, - "value": "class" + } }, { "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, - "value": "Foo" + } }, { "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "{" + } }, { "type": "Identifier", + "value": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 2, + "column": 13 } - }, - "value": "constructor" + } }, { "type": "Punctuator", + "value": "(", "range": [ 25, 26 ], "loc": { - "end": { - "line": 2, - "column": 14 - }, "start": { "line": 2, "column": 13 + }, + "end": { + "line": 2, + "column": 14 } - }, - "value": "(" + } }, { "type": "Keyword", + "value": "private", "range": [ 26, 33 ], "loc": { - "end": { + "start": { "line": 2, - "column": 21 + "column": 14 }, - "start": { + "end": { "line": 2, - "column": 14 + "column": 21 } - }, - "value": "private" + } }, { "type": "Identifier", + "value": "firstName", "range": [ 34, 43 ], "loc": { - "end": { - "line": 2, - "column": 31 - }, "start": { "line": 2, "column": 22 + }, + "end": { + "line": 2, + "column": 31 } - }, - "value": "firstName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 43, 44 ], "loc": { - "end": { - "line": 2, - "column": 32 - }, "start": { "line": 2, "column": 31 + }, + "end": { + "line": 2, + "column": 32 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 45, 51 ], "loc": { - "end": { - "line": 2, - "column": 39 - }, "start": { "line": 2, "column": 33 + }, + "end": { + "line": 2, + "column": 39 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 51, 52 ], "loc": { - "end": { - "line": 2, - "column": 40 - }, "start": { "line": 2, "column": 39 + }, + "end": { + "line": 2, + "column": 40 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "private", "range": [ 67, 74 ], "loc": { - "end": { - "line": 3, - "column": 21 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 21 } - }, - "value": "private" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 75, 83 ], "loc": { - "end": { - "line": 3, - "column": 30 - }, "start": { "line": 3, "column": 22 + }, + "end": { + "line": 3, + "column": 30 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "lastName", "range": [ 84, 92 ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 31 + }, + "end": { + "line": 3, + "column": 39 } - }, - "value": "lastName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 92, 93 ], "loc": { - "end": { - "line": 3, - "column": 40 - }, "start": { "line": 3, "column": 39 + }, + "end": { + "line": 3, + "column": 40 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 94, 100 ], "loc": { - "end": { - "line": 3, - "column": 47 - }, "start": { "line": 3, "column": 41 + }, + "end": { + "line": 3, + "column": 47 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 100, 101 ], "loc": { - "end": { - "line": 3, - "column": 48 - }, "start": { "line": 3, "column": 47 + }, + "end": { + "line": 3, + "column": 48 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "private", "range": [ 116, 123 ], "loc": { - "end": { - "line": 4, - "column": 21 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 21 } - }, - "value": "private" + } }, { "type": "Identifier", + "value": "age", "range": [ 124, 127 ], "loc": { - "end": { - "line": 4, - "column": 25 - }, "start": { "line": 4, "column": 22 + }, + "end": { + "line": 4, + "column": 25 } - }, - "value": "age" + } }, { "type": "Punctuator", + "value": ":", "range": [ 127, 128 ], "loc": { - "end": { - "line": 4, - "column": 26 - }, "start": { "line": 4, "column": 25 + }, + "end": { + "line": 4, + "column": 26 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "number", "range": [ 129, 135 ], "loc": { - "end": { - "line": 4, - "column": 33 - }, "start": { "line": 4, "column": 27 + }, + "end": { + "line": 4, + "column": 33 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": "=", "range": [ 136, 137 ], "loc": { - "end": { - "line": 4, - "column": 35 - }, "start": { "line": 4, "column": 34 + }, + "end": { + "line": 4, + "column": 35 } - }, - "value": "=" + } }, { "type": "Numeric", + "value": "30", "range": [ 138, 140 ], "loc": { - "end": { - "line": 4, - "column": 38 - }, "start": { "line": 4, "column": 36 + }, + "end": { + "line": 4, + "column": 38 } - }, - "value": "30" + } }, { "type": "Punctuator", + "value": ",", "range": [ 140, 141 ], "loc": { - "end": { - "line": 4, - "column": 39 - }, "start": { "line": 4, "column": 38 + }, + "end": { + "line": 4, + "column": 39 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "private", "range": [ 156, 163 ], "loc": { - "end": { - "line": 5, - "column": 21 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 21 } - }, - "value": "private" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 164, 172 ], "loc": { - "end": { - "line": 5, - "column": 30 - }, "start": { "line": 5, "column": 22 + }, + "end": { + "line": 5, + "column": 30 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "student", "range": [ 173, 180 ], "loc": { - "end": { - "line": 5, - "column": 38 - }, "start": { "line": 5, "column": 31 + }, + "end": { + "line": 5, + "column": 38 } - }, - "value": "student" + } }, { "type": "Punctuator", + "value": ":", "range": [ 180, 181 ], "loc": { - "end": { - "line": 5, - "column": 39 - }, "start": { "line": 5, "column": 38 + }, + "end": { + "line": 5, + "column": 39 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "boolean", "range": [ 182, 189 ], "loc": { - "end": { - "line": 5, - "column": 47 - }, "start": { "line": 5, "column": 40 + }, + "end": { + "line": 5, + "column": 47 } - }, - "value": "boolean" + } }, { "type": "Punctuator", + "value": "=", "range": [ 190, 191 ], "loc": { - "end": { - "line": 5, - "column": 49 - }, "start": { "line": 5, "column": 48 + }, + "end": { + "line": 5, + "column": 49 } - }, - "value": "=" + } }, { "type": "Boolean", + "value": "false", "range": [ 192, 197 ], "loc": { - "end": { - "line": 5, - "column": 55 - }, "start": { "line": 5, "column": 50 + }, + "end": { + "line": 5, + "column": 55 } - }, - "value": "false" + } }, { "type": "Punctuator", + "value": ")", "range": [ 197, 198 ], "loc": { - "end": { - "line": 5, - "column": 56 - }, "start": { "line": 5, "column": 55 + }, + "end": { + "line": 5, + "column": 56 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": "{", "range": [ 199, 200 ], "loc": { - "end": { - "line": 5, - "column": 58 - }, "start": { "line": 5, "column": 57 + }, + "end": { + "line": 5, + "column": 58 } - }, - "value": "{" + } }, { "type": "Punctuator", + "value": "}", "range": [ 200, 201 ], "loc": { - "end": { - "line": 5, - "column": 59 - }, "start": { "line": 5, "column": 58 + }, + "end": { + "line": 5, + "column": 59 } - }, - "value": "}" + } }, { "type": "Punctuator", + "value": "}", "range": [ 202, 203 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 6, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } - }, - "value": "}" + } } - ], -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-protected-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-protected-parameter-properties.result.js index 3ff625a..0d44bed 100644 --- a/tests/fixtures/typescript/basics/class-with-protected-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-protected-parameter-properties.result.js @@ -5,13 +5,13 @@ module.exports = { 211 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } }, "body": [ @@ -22,31 +22,35 @@ module.exports = { 211 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } }, - "body": { - "type": "ClassBody", + "id": { + "type": "Identifier", "range": [ - 10, - 211 + 6, + 9 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, - "column": 10 + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } }, + "name": "Foo" + }, + "body": { + "type": "ClassBody", "body": [ { "type": "MethodDefinition", @@ -55,74 +59,35 @@ module.exports = { 209 ], "loc": { - "end": { - "line": 5, - "column": 61 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 5, + "column": 61 } }, - "kind": "constructor", - "accessibility": null, - "computed": false, "key": { "type": "Identifier", + "name": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 - } - }, - "name": "constructor" - }, - "static": false, - "value": { - "type": "FunctionExpression", - "range": [ - 25, - 209 - ], - "loc": { - "end": { - "line": 5, - "column": 61 }, - "start": { + "end": { "line": 2, "column": 13 } - }, - "async": false, - "body": { - "type": "BlockStatement", - "range": [ - 207, - 209 - ], - "loc": { - "end": { - "line": 5, - "column": 61 - }, - "start": { - "line": 5, - "column": 59 - } - }, - "body": [] - }, - "expression": false, - "generator": false, + } + }, + "value": { + "type": "FunctionExpression", "id": null, "params": [ { @@ -132,20 +97,19 @@ module.exports = { 53 ], "loc": { - "end": { - "line": 2, - "column": 41 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 41 } }, - "decorators": [], "accessibility": "protected", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "Identifier", "range": [ @@ -153,32 +117,32 @@ module.exports = { 45 ], "loc": { - "end": { - "line": 2, - "column": 33 - }, "start": { "line": 2, "column": 24 + }, + "end": { + "line": 2, + "column": 33 } }, "name": "firstName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 47, - 53 - ], "loc": { - "end": { - "line": 2, - "column": 41 - }, "start": { "line": 2, "column": 35 + }, + "end": { + "line": 2, + "column": 41 } }, + "range": [ + 47, + 53 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -186,18 +150,19 @@ module.exports = { 53 ], "loc": { - "end": { - "line": 2, - "column": 41 - }, "start": { "line": 2, "column": 35 + }, + "end": { + "line": 2, + "column": 41 } } } } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -206,20 +171,19 @@ module.exports = { 104 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 49 } }, - "decorators": [], "accessibility": "protected", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "Identifier", "range": [ @@ -227,32 +191,32 @@ module.exports = { 96 ], "loc": { - "end": { - "line": 3, - "column": 41 - }, "start": { "line": 3, "column": 33 + }, + "end": { + "line": 3, + "column": 41 } }, "name": "lastName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 98, - 104 - ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 43 + }, + "end": { + "line": 3, + "column": 49 } }, + "range": [ + 98, + 104 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -260,18 +224,19 @@ module.exports = { 104 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 43 + }, + "end": { + "line": 3, + "column": 49 } } } } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -280,20 +245,19 @@ module.exports = { 146 ], "loc": { - "end": { - "line": 4, - "column": 40 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 40 } }, - "decorators": [], "accessibility": "protected", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "AssignmentPattern", "range": [ @@ -301,13 +265,13 @@ module.exports = { 146 ], "loc": { - "end": { - "line": 4, - "column": 40 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 40 } }, "left": { @@ -317,32 +281,32 @@ module.exports = { 133 ], "loc": { - "end": { - "line": 4, - "column": 27 - }, "start": { "line": 4, "column": 24 + }, + "end": { + "line": 4, + "column": 27 } }, "name": "age", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 135, - 141 - ], "loc": { - "end": { - "line": 4, - "column": 35 - }, "start": { "line": 4, "column": 29 + }, + "end": { + "line": 4, + "column": 35 } }, + "range": [ + 135, + 141 + ], "typeAnnotation": { "type": "TSNumberKeyword", "range": [ @@ -350,13 +314,13 @@ module.exports = { 141 ], "loc": { - "end": { - "line": 4, - "column": 35 - }, "start": { "line": 4, "column": 29 + }, + "end": { + "line": 4, + "column": 35 } } } @@ -369,19 +333,20 @@ module.exports = { 146 ], "loc": { - "end": { - "line": 4, - "column": 40 - }, "start": { "line": 4, "column": 38 + }, + "end": { + "line": 4, + "column": 40 } }, - "raw": "30", - "value": 30 + "value": 30, + "raw": "30" } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -390,20 +355,19 @@ module.exports = { 205 ], "loc": { - "end": { - "line": 5, - "column": 57 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 57 } }, - "decorators": [], "accessibility": "protected", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "AssignmentPattern", "range": [ @@ -411,13 +375,13 @@ module.exports = { 205 ], "loc": { - "end": { - "line": 5, - "column": 57 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 57 } }, "left": { @@ -427,32 +391,32 @@ module.exports = { 188 ], "loc": { - "end": { - "line": 5, - "column": 40 - }, "start": { "line": 5, "column": 33 + }, + "end": { + "line": 5, + "column": 40 } }, "name": "student", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 190, - 197 - ], "loc": { - "end": { - "line": 5, - "column": 49 - }, "start": { "line": 5, "column": 42 + }, + "end": { + "line": 5, + "column": 49 } }, + "range": [ + 190, + 197 + ], "typeAnnotation": { "type": "TSBooleanKeyword", "range": [ @@ -460,13 +424,13 @@ module.exports = { 197 ], "loc": { - "end": { - "line": 5, - "column": 49 - }, "start": { "line": 5, "column": 42 + }, + "end": { + "line": 5, + "column": 49 } } } @@ -479,661 +443,697 @@ module.exports = { 205 ], "loc": { - "end": { - "line": 5, - "column": 57 - }, "start": { "line": 5, "column": 52 + }, + "end": { + "line": 5, + "column": 57 } }, - "raw": "false", - "value": false + "value": false, + "raw": "false" } + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 207, + 209 + ], + "loc": { + "start": { + "line": 5, + "column": 59 + }, + "end": { + "line": 5, + "column": 61 } + }, + "body": [] + }, + "range": [ + 25, + 209 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 5, + "column": 61 } - ] - } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" } - ] - }, - "decorators": [], - "id": { - "type": "Identifier", + ], "range": [ - 6, - 9 + 10, + 211 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, - "column": 6 + "column": 10 + }, + "end": { + "line": 6, + "column": 1 } - }, - "name": "Foo", + } }, - "implements": [], "superClass": null, + "implements": [], + "decorators": [] } ], "sourceType": "script", "tokens": [ { "type": "Keyword", + "value": "class", "range": [ 0, 5 ], "loc": { - "end": { - "line": 1, - "column": 5 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, - "value": "class" + } }, { "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, - "value": "Foo" + } }, { "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "{" + } }, { "type": "Identifier", + "value": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 2, + "column": 13 } - }, - "value": "constructor" + } }, { "type": "Punctuator", + "value": "(", "range": [ 25, 26 ], "loc": { - "end": { - "line": 2, - "column": 14 - }, "start": { "line": 2, "column": 13 + }, + "end": { + "line": 2, + "column": 14 } - }, - "value": "(" + } }, { "type": "Keyword", + "value": "protected", "range": [ 26, 35 ], "loc": { - "end": { - "line": 2, - "column": 23 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 23 } - }, - "value": "protected" + } }, { "type": "Identifier", + "value": "firstName", "range": [ 36, 45 ], "loc": { - "end": { - "line": 2, - "column": 33 - }, "start": { "line": 2, "column": 24 + }, + "end": { + "line": 2, + "column": 33 } - }, - "value": "firstName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 45, 46 ], "loc": { - "end": { - "line": 2, - "column": 34 - }, "start": { "line": 2, "column": 33 + }, + "end": { + "line": 2, + "column": 34 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 47, 53 ], "loc": { - "end": { - "line": 2, - "column": 41 - }, "start": { "line": 2, "column": 35 + }, + "end": { + "line": 2, + "column": 41 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 53, 54 ], "loc": { - "end": { - "line": 2, - "column": 42 - }, "start": { "line": 2, "column": 41 + }, + "end": { + "line": 2, + "column": 42 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "protected", "range": [ 69, 78 ], "loc": { - "end": { - "line": 3, - "column": 23 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 23 } - }, - "value": "protected" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 79, 87 ], "loc": { - "end": { - "line": 3, - "column": 32 - }, "start": { "line": 3, "column": 24 + }, + "end": { + "line": 3, + "column": 32 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "lastName", "range": [ 88, 96 ], "loc": { - "end": { - "line": 3, - "column": 41 - }, "start": { "line": 3, "column": 33 + }, + "end": { + "line": 3, + "column": 41 } - }, - "value": "lastName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 96, 97 ], "loc": { - "end": { - "line": 3, - "column": 42 - }, "start": { "line": 3, "column": 41 + }, + "end": { + "line": 3, + "column": 42 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 98, 104 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 43 + }, + "end": { + "line": 3, + "column": 49 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 104, 105 ], "loc": { - "end": { - "line": 3, - "column": 50 - }, "start": { "line": 3, "column": 49 + }, + "end": { + "line": 3, + "column": 50 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "protected", "range": [ 120, 129 ], "loc": { - "end": { - "line": 4, - "column": 23 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 23 } - }, - "value": "protected" + } }, { "type": "Identifier", + "value": "age", "range": [ 130, 133 ], "loc": { - "end": { - "line": 4, - "column": 27 - }, "start": { "line": 4, "column": 24 - } - }, - "value": "age" - }, - { - "loc": { - "end": { - "line": 4, - "column": 28 }, - "start": { + "end": { "line": 4, "column": 27 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 133, 134 ], - "type": "Punctuator", - "value": ":" + "loc": { + "start": { + "line": 4, + "column": 27 + }, + "end": { + "line": 4, + "column": 28 + } + } }, { "type": "Identifier", + "value": "number", "range": [ 135, 141 ], "loc": { - "end": { - "line": 4, - "column": 35 - }, "start": { "line": 4, "column": 29 + }, + "end": { + "line": 4, + "column": 35 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": "=", "range": [ 142, 143 ], "loc": { - "end": { - "line": 4, - "column": 37 - }, "start": { "line": 4, "column": 36 + }, + "end": { + "line": 4, + "column": 37 } - }, - "value": "=" + } }, { "type": "Numeric", + "value": "30", "range": [ 144, 146 ], "loc": { - "end": { - "line": 4, - "column": 40 - }, "start": { "line": 4, "column": 38 + }, + "end": { + "line": 4, + "column": 40 } - }, - "value": "30" + } }, { "type": "Punctuator", + "value": ",", "range": [ 146, 147 ], "loc": { - "end": { - "line": 4, - "column": 41 - }, "start": { "line": 4, "column": 40 + }, + "end": { + "line": 4, + "column": 41 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "protected", "range": [ 162, 171 ], "loc": { - "end": { - "line": 5, - "column": 23 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 23 } - }, - "value": "protected" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 172, 180 ], "loc": { - "end": { - "line": 5, - "column": 32 - }, "start": { "line": 5, "column": 24 + }, + "end": { + "line": 5, + "column": 32 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "student", "range": [ 181, 188 ], "loc": { - "end": { - "line": 5, - "column": 40 - }, "start": { "line": 5, "column": 33 + }, + "end": { + "line": 5, + "column": 40 } - }, - "value": "student" + } }, { "type": "Punctuator", + "value": ":", "range": [ 188, 189 ], "loc": { - "end": { - "line": 5, - "column": 41 - }, "start": { "line": 5, "column": 40 + }, + "end": { + "line": 5, + "column": 41 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "boolean", "range": [ 190, 197 ], "loc": { - "end": { - "line": 5, - "column": 49 - }, "start": { "line": 5, "column": 42 + }, + "end": { + "line": 5, + "column": 49 } - }, - "value": "boolean" + } }, { "type": "Punctuator", + "value": "=", "range": [ 198, 199 ], "loc": { - "end": { - "line": 5, - "column": 51 - }, "start": { "line": 5, "column": 50 + }, + "end": { + "line": 5, + "column": 51 } - }, - "value": "=" + } }, { "type": "Boolean", + "value": "false", "range": [ 200, 205 ], "loc": { - "end": { - "line": 5, - "column": 57 - }, "start": { "line": 5, "column": 52 + }, + "end": { + "line": 5, + "column": 57 } - }, - "value": "false" + } }, { "type": "Punctuator", + "value": ")", "range": [ 205, 206 ], "loc": { - "end": { - "line": 5, - "column": 58 - }, "start": { "line": 5, "column": 57 + }, + "end": { + "line": 5, + "column": 58 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": "{", "range": [ 207, 208 ], "loc": { - "end": { - "line": 5, - "column": 60 - }, "start": { "line": 5, "column": 59 + }, + "end": { + "line": 5, + "column": 60 } - }, - "value": "{" + } }, { "type": "Punctuator", + "value": "}", "range": [ 208, 209 ], "loc": { - "end": { - "line": 5, - "column": 61 - }, "start": { "line": 5, "column": 60 + }, + "end": { + "line": 5, + "column": 61 } - }, - "value": "}" + } }, { "type": "Punctuator", + "value": "}", "range": [ 210, 211 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 6, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } - }, - "value": "}" + } } - ], -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-public-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-public-parameter-properties.result.js index 14de49a..8c8c738 100644 --- a/tests/fixtures/typescript/basics/class-with-public-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-public-parameter-properties.result.js @@ -5,13 +5,13 @@ module.exports = { 199 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } }, "body": [ @@ -22,31 +22,35 @@ module.exports = { 199 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } }, - "body": { - "type": "ClassBody", + "id": { + "type": "Identifier", "range": [ - 10, - 199 + 6, + 9 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 1, - "column": 10 + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } }, + "name": "Foo" + }, + "body": { + "type": "ClassBody", "body": [ { "type": "MethodDefinition", @@ -55,74 +59,35 @@ module.exports = { 197 ], "loc": { - "end": { - "line": 5, - "column": 58 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 5, + "column": 58 } }, - "kind": "constructor", - "accessibility": null, - "computed": false, "key": { "type": "Identifier", + "name": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 - } - }, - "name": "constructor" - }, - "static": false, - "value": { - "type": "FunctionExpression", - "range": [ - 25, - 197 - ], - "loc": { - "end": { - "line": 5, - "column": 58 }, - "start": { + "end": { "line": 2, "column": 13 } - }, - "async": false, - "body": { - "type": "BlockStatement", - "range": [ - 195, - 197 - ], - "loc": { - "end": { - "line": 5, - "column": 58 - }, - "start": { - "line": 5, - "column": 56 - } - }, - "body": [] - }, - "expression": false, - "generator": false, + } + }, + "value": { + "type": "FunctionExpression", "id": null, "params": [ { @@ -132,20 +97,19 @@ module.exports = { 50 ], "loc": { - "end": { - "line": 2, - "column": 38 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 38 } }, - "decorators": [], "accessibility": "public", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "Identifier", "range": [ @@ -153,32 +117,32 @@ module.exports = { 42 ], "loc": { - "end": { - "line": 2, - "column": 30 - }, "start": { "line": 2, "column": 21 + }, + "end": { + "line": 2, + "column": 30 } }, "name": "firstName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 44, - 50 - ], "loc": { - "end": { - "line": 2, - "column": 38 - }, "start": { "line": 2, "column": 32 + }, + "end": { + "line": 2, + "column": 38 } }, + "range": [ + 44, + 50 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -186,18 +150,19 @@ module.exports = { 50 ], "loc": { - "end": { - "line": 2, - "column": 38 - }, "start": { "line": 2, "column": 32 + }, + "end": { + "line": 2, + "column": 38 } } } } }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -206,20 +171,19 @@ module.exports = { 98 ], "loc": { - "end": { - "line": 3, - "column": 46 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 46 } }, - "decorators": [], "accessibility": "public", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "Identifier", "range": [ @@ -227,32 +191,32 @@ module.exports = { 90 ], "loc": { - "end": { - "line": 3, - "column": 38 - }, "start": { "line": 3, "column": 30 + }, + "end": { + "line": 3, + "column": 38 } }, "name": "lastName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 92, - 98 - ], "loc": { - "end": { - "line": 3, - "column": 46 - }, "start": { "line": 3, "column": 40 + }, + "end": { + "line": 3, + "column": 46 } }, + "range": [ + 92, + 98 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -260,18 +224,19 @@ module.exports = { 98 ], "loc": { - "end": { - "line": 3, - "column": 46 - }, "start": { "line": 3, "column": 40 + }, + "end": { + "line": 3, + "column": 46 } } } } }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -280,20 +245,19 @@ module.exports = { 137 ], "loc": { - "end": { - "line": 4, - "column": 37 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 37 } }, - "decorators": [], "accessibility": "public", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "AssignmentPattern", "range": [ @@ -301,13 +265,13 @@ module.exports = { 137 ], "loc": { - "end": { - "line": 4, - "column": 37 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 37 } }, "left": { @@ -317,32 +281,32 @@ module.exports = { 124 ], "loc": { - "end": { - "line": 4, - "column": 24 - }, "start": { "line": 4, "column": 21 + }, + "end": { + "line": 4, + "column": 24 } }, "name": "age", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 126, - 132 - ], "loc": { - "end": { - "line": 4, - "column": 32 - }, "start": { "line": 4, "column": 26 + }, + "end": { + "line": 4, + "column": 32 } }, + "range": [ + 126, + 132 + ], "typeAnnotation": { "type": "TSNumberKeyword", "range": [ @@ -350,13 +314,13 @@ module.exports = { 132 ], "loc": { - "end": { - "line": 4, - "column": 32 - }, "start": { "line": 4, "column": 26 + }, + "end": { + "line": 4, + "column": 32 } } } @@ -369,19 +333,20 @@ module.exports = { 137 ], "loc": { - "end": { - "line": 4, - "column": 37 - }, "start": { "line": 4, "column": 35 + }, + "end": { + "line": 4, + "column": 37 } }, - "raw": "30", - "value": 30 + "value": 30, + "raw": "30" } }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -390,20 +355,19 @@ module.exports = { 193 ], "loc": { - "end": { - "line": 5, - "column": 54 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 54 } }, - "decorators": [], "accessibility": "public", + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "AssignmentPattern", "range": [ @@ -411,13 +375,13 @@ module.exports = { 193 ], "loc": { - "end": { - "line": 5, - "column": 54 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 54 } }, "left": { @@ -427,32 +391,32 @@ module.exports = { 176 ], "loc": { - "end": { - "line": 5, - "column": 37 - }, "start": { "line": 5, "column": 30 + }, + "end": { + "line": 5, + "column": 37 } }, "name": "student", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 178, - 185 - ], "loc": { - "end": { - "line": 5, - "column": 46 - }, "start": { "line": 5, "column": 39 + }, + "end": { + "line": 5, + "column": 46 } }, + "range": [ + 178, + 185 + ], "typeAnnotation": { "type": "TSBooleanKeyword", "range": [ @@ -460,13 +424,13 @@ module.exports = { 185 ], "loc": { - "end": { - "line": 5, - "column": 46 - }, "start": { "line": 5, "column": 39 + }, + "end": { + "line": 5, + "column": 46 } } } @@ -479,661 +443,697 @@ module.exports = { 193 ], "loc": { - "end": { - "line": 5, - "column": 54 - }, "start": { "line": 5, "column": 49 + }, + "end": { + "line": 5, + "column": 54 } }, - "raw": "false", - "value": false + "value": false, + "raw": "false" } + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 195, + 197 + ], + "loc": { + "start": { + "line": 5, + "column": 56 + }, + "end": { + "line": 5, + "column": 58 } + }, + "body": [] + }, + "range": [ + 25, + 197 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 5, + "column": 58 } - ] - } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" } - ] - }, - "decorators": [], - "id": { - "type": "Identifier", + ], "range": [ - 6, - 9 + 10, + 199 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, - "column": 6 + "column": 10 + }, + "end": { + "line": 6, + "column": 1 } - }, - "name": "Foo" + } }, + "superClass": null, "implements": [], - "superClass": null + "decorators": [] } ], "sourceType": "script", "tokens": [ { "type": "Keyword", + "value": "class", "range": [ 0, 5 ], "loc": { - "end": { - "line": 1, - "column": 5 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, - "value": "class" + } }, { "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, - "value": "Foo" + } }, { "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "{" + } }, { "type": "Identifier", + "value": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 2, + "column": 13 } - }, - "value": "constructor" + } }, { "type": "Punctuator", + "value": "(", "range": [ 25, 26 ], "loc": { - "end": { - "line": 2, - "column": 14 - }, "start": { "line": 2, "column": 13 + }, + "end": { + "line": 2, + "column": 14 } - }, - "value": "(" + } }, { "type": "Keyword", + "value": "public", "range": [ 26, 32 ], "loc": { - "end": { + "start": { "line": 2, - "column": 20 + "column": 14 }, - "start": { + "end": { "line": 2, - "column": 14 + "column": 20 } - }, - "value": "public" + } }, { "type": "Identifier", + "value": "firstName", "range": [ 33, 42 ], "loc": { - "end": { - "line": 2, - "column": 30 - }, "start": { "line": 2, "column": 21 + }, + "end": { + "line": 2, + "column": 30 } - }, - "value": "firstName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 42, 43 ], "loc": { - "end": { - "line": 2, - "column": 31 - }, "start": { "line": 2, "column": 30 + }, + "end": { + "line": 2, + "column": 31 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 44, 50 ], "loc": { - "end": { - "line": 2, - "column": 38 - }, "start": { "line": 2, "column": 32 + }, + "end": { + "line": 2, + "column": 38 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 50, 51 ], "loc": { - "end": { - "line": 2, - "column": 39 - }, "start": { "line": 2, "column": 38 + }, + "end": { + "line": 2, + "column": 39 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "public", "range": [ 66, 72 ], "loc": { - "end": { - "line": 3, - "column": 20 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 20 } - }, - "value": "public" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 73, 81 ], "loc": { - "end": { - "line": 3, - "column": 29 - }, "start": { "line": 3, "column": 21 + }, + "end": { + "line": 3, + "column": 29 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "lastName", "range": [ 82, 90 ], "loc": { - "end": { - "line": 3, - "column": 38 - }, "start": { "line": 3, "column": 30 + }, + "end": { + "line": 3, + "column": 38 } - }, - "value": "lastName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 90, 91 ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 38 + }, + "end": { + "line": 3, + "column": 39 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 92, 98 ], "loc": { - "end": { - "line": 3, - "column": 46 - }, "start": { "line": 3, "column": 40 + }, + "end": { + "line": 3, + "column": 46 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 98, 99 ], "loc": { - "end": { - "line": 3, - "column": 47 - }, "start": { "line": 3, "column": 46 + }, + "end": { + "line": 3, + "column": 47 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "public", "range": [ 114, 120 ], "loc": { - "end": { - "line": 4, - "column": 20 - }, "start": { "line": 4, "column": 14 + }, + "end": { + "line": 4, + "column": 20 } - }, - "value": "public" + } }, { "type": "Identifier", + "value": "age", "range": [ 121, 124 ], "loc": { - "end": { - "line": 4, - "column": 24 - }, "start": { "line": 4, "column": 21 + }, + "end": { + "line": 4, + "column": 24 } - }, - "value": "age" + } }, { "type": "Punctuator", + "value": ":", "range": [ 124, 125 ], "loc": { - "end": { - "line": 4, - "column": 25 - }, "start": { "line": 4, "column": 24 + }, + "end": { + "line": 4, + "column": 25 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "number", "range": [ 126, 132 ], "loc": { - "end": { - "line": 4, - "column": 32 - }, "start": { "line": 4, "column": 26 + }, + "end": { + "line": 4, + "column": 32 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": "=", "range": [ 133, 134 ], "loc": { - "end": { - "line": 4, - "column": 34 - }, "start": { "line": 4, "column": 33 + }, + "end": { + "line": 4, + "column": 34 } - }, - "value": "=" + } }, { "type": "Numeric", + "value": "30", "range": [ 135, 137 ], "loc": { - "end": { - "line": 4, - "column": 37 - }, "start": { "line": 4, "column": 35 + }, + "end": { + "line": 4, + "column": 37 } - }, - "value": "30" + } }, { "type": "Punctuator", + "value": ",", "range": [ 137, 138 ], "loc": { - "end": { - "line": 4, - "column": 38 - }, "start": { "line": 4, "column": 37 + }, + "end": { + "line": 4, + "column": 38 } - }, - "value": "," + } }, { "type": "Keyword", + "value": "public", "range": [ 153, 159 ], "loc": { - "end": { - "line": 5, - "column": 20 - }, "start": { "line": 5, "column": 14 + }, + "end": { + "line": 5, + "column": 20 } - }, - "value": "public" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 160, 168 ], "loc": { - "end": { - "line": 5, - "column": 29 - }, "start": { "line": 5, "column": 21 + }, + "end": { + "line": 5, + "column": 29 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "student", "range": [ 169, 176 ], "loc": { - "end": { - "line": 5, - "column": 37 - }, "start": { "line": 5, "column": 30 + }, + "end": { + "line": 5, + "column": 37 } - }, - "value": "student" + } }, { "type": "Punctuator", + "value": ":", "range": [ 176, 177 ], "loc": { - "end": { - "line": 5, - "column": 38 - }, "start": { "line": 5, "column": 37 + }, + "end": { + "line": 5, + "column": 38 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "boolean", "range": [ 178, 185 ], "loc": { - "end": { - "line": 5, - "column": 46 - }, "start": { "line": 5, "column": 39 + }, + "end": { + "line": 5, + "column": 46 } - }, - "value": "boolean" + } }, { "type": "Punctuator", + "value": "=", "range": [ 186, 187 ], "loc": { - "end": { - "line": 5, - "column": 48 - }, "start": { "line": 5, "column": 47 + }, + "end": { + "line": 5, + "column": 48 } - }, - "value": "=" + } }, { "type": "Boolean", + "value": "false", "range": [ 188, 193 ], "loc": { - "end": { - "line": 5, - "column": 54 - }, "start": { "line": 5, "column": 49 + }, + "end": { + "line": 5, + "column": 54 } - }, - "value": "false" + } }, { "type": "Punctuator", + "value": ")", "range": [ 193, 194 ], "loc": { - "end": { - "line": 5, - "column": 55 - }, "start": { "line": 5, "column": 54 + }, + "end": { + "line": 5, + "column": 55 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": "{", "range": [ 195, 196 ], "loc": { - "end": { - "line": 5, - "column": 57 - }, "start": { "line": 5, "column": 56 + }, + "end": { + "line": 5, + "column": 57 } - }, - "value": "{" + } }, { "type": "Punctuator", + "value": "}", "range": [ 196, 197 ], "loc": { - "end": { - "line": 5, - "column": 58 - }, "start": { "line": 5, "column": 57 + }, + "end": { + "line": 5, + "column": 58 } - }, - "value": "}" + } }, { "type": "Punctuator", + "value": "}", "range": [ 198, 199 ], "loc": { - "end": { - "line": 6, - "column": 1 - }, "start": { "line": 6, "column": 0 + }, + "end": { + "line": 6, + "column": 1 } - }, - "value": "}" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-readonly-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-readonly-parameter-properties.result.js index 5ecb341..33c3979 100644 --- a/tests/fixtures/typescript/basics/class-with-readonly-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-readonly-parameter-properties.result.js @@ -5,13 +5,13 @@ module.exports = { 109 ], "loc": { - "end": { - "line": 4, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 4, + "column": 1 } }, "body": [ @@ -22,31 +22,35 @@ module.exports = { 109 ], "loc": { - "end": { - "line": 4, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 4, + "column": 1 } }, - "body": { - "type": "ClassBody", + "id": { + "type": "Identifier", "range": [ - 10, - 109 + 6, + 9 ], "loc": { - "end": { - "line": 4, - "column": 1 - }, "start": { "line": 1, - "column": 10 + "column": 6 + }, + "end": { + "line": 1, + "column": 9 } }, + "name": "Foo" + }, + "body": { + "type": "ClassBody", "body": [ { "type": "MethodDefinition", @@ -55,74 +59,35 @@ module.exports = { 107 ], "loc": { - "end": { - "line": 3, - "column": 53 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 3, + "column": 53 } }, - "kind": "constructor", - "accessibility": null, - "computed": false, "key": { "type": "Identifier", + "name": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 - } - }, - "name": "constructor" - }, - "static": false, - "value": { - "type": "FunctionExpression", - "range": [ - 25, - 107 - ], - "loc": { - "end": { - "line": 3, - "column": 53 }, - "start": { + "end": { "line": 2, "column": 13 } - }, - "async": false, - "body": { - "type": "BlockStatement", - "range": [ - 105, - 107 - ], - "loc": { - "end": { - "line": 3, - "column": 53 - }, - "start": { - "line": 3, - "column": 51 - } - }, - "body": [] - }, - "expression": false, - "generator": false, + } + }, + "value": { + "type": "FunctionExpression", "id": null, "params": [ { @@ -132,20 +97,19 @@ module.exports = { 52 ], "loc": { - "end": { - "line": 2, - "column": 40 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 40 } }, - "decorators": [], "accessibility": null, + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "Identifier", "range": [ @@ -153,32 +117,32 @@ module.exports = { 44 ], "loc": { - "end": { - "line": 2, - "column": 32 - }, "start": { "line": 2, "column": 23 + }, + "end": { + "line": 2, + "column": 32 } }, "name": "firstName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 46, - 52 - ], "loc": { - "end": { - "line": 2, - "column": 40 - }, "start": { "line": 2, "column": 34 + }, + "end": { + "line": 2, + "column": 40 } }, + "range": [ + 46, + 52 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -186,18 +150,19 @@ module.exports = { 52 ], "loc": { - "end": { - "line": 2, - "column": 40 - }, "start": { "line": 2, "column": 34 + }, + "end": { + "line": 2, + "column": 40 } } } } - } + }, + "decorators": [] }, { "type": "TSParameterProperty", @@ -206,20 +171,19 @@ module.exports = { 103 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 49 } }, - "decorators": [], "accessibility": null, + "readonly": true, "static": false, "export": false, - "readonly": true, "parameter": { "type": "AssignmentPattern", "range": [ @@ -227,13 +191,13 @@ module.exports = { 103 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 49 } }, "left": { @@ -243,32 +207,32 @@ module.exports = { 85 ], "loc": { - "end": { - "line": 3, - "column": 31 - }, "start": { "line": 3, "column": 23 + }, + "end": { + "line": 3, + "column": 31 } }, "name": "lastName", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 87, - 93 - ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 33 + }, + "end": { + "line": 3, + "column": 39 } }, + "range": [ + 87, + 93 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -276,13 +240,13 @@ module.exports = { 93 ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 33 + }, + "end": { + "line": 3, + "column": 39 } } } @@ -295,409 +259,445 @@ module.exports = { 103 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 42 + }, + "end": { + "line": 3, + "column": 49 } }, - "raw": "'Smith'", - "value": "Smith" - }, + "value": "Smith", + "raw": "'Smith'" + } + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 105, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 51 + }, + "end": { + "line": 3, + "column": 53 } + }, + "body": [] + }, + "range": [ + 25, + 107 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 3, + "column": 53 } - ] - } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" } - ] - }, - "decorators": [], - "id": { - "type": "Identifier", + ], "range": [ - 6, - 9 + 10, + 109 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, - "column": 6 + "column": 10 + }, + "end": { + "line": 4, + "column": 1 } - }, - "name": "Foo" + } }, + "superClass": null, "implements": [], - "superClass": null + "decorators": [] } ], "sourceType": "script", "tokens": [ { "type": "Keyword", + "value": "class", "range": [ 0, 5 ], "loc": { - "end": { - "line": 1, - "column": 5 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, - "value": "class" + } }, { "type": "Identifier", + "value": "Foo", "range": [ 6, 9 ], "loc": { - "end": { - "line": 1, - "column": 9 - }, "start": { "line": 1, "column": 6 + }, + "end": { + "line": 1, + "column": 9 } - }, - "value": "Foo" + } }, { "type": "Punctuator", + "value": "{", "range": [ 10, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "{" + } }, { "type": "Identifier", + "value": "constructor", "range": [ 14, 25 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 2, + "column": 13 } - }, - "value": "constructor" + } }, { "type": "Punctuator", + "value": "(", "range": [ 25, 26 ], "loc": { - "end": { - "line": 2, - "column": 14 - }, "start": { "line": 2, "column": 13 + }, + "end": { + "line": 2, + "column": 14 } - }, - "value": "(" + } }, { "type": "Identifier", + "value": "readonly", "range": [ 26, 34 ], "loc": { - "end": { - "line": 2, - "column": 22 - }, "start": { "line": 2, "column": 14 + }, + "end": { + "line": 2, + "column": 22 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "firstName", "range": [ 35, 44 ], "loc": { - "end": { - "line": 2, - "column": 32 - }, "start": { "line": 2, "column": 23 + }, + "end": { + "line": 2, + "column": 32 } - }, - "value": "firstName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 44, 45 ], "loc": { - "end": { - "line": 2, - "column": 33 - }, "start": { "line": 2, "column": 32 + }, + "end": { + "line": 2, + "column": 33 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 46, 52 ], "loc": { - "end": { - "line": 2, - "column": 40 - }, "start": { "line": 2, "column": 34 + }, + "end": { + "line": 2, + "column": 40 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 52, 53 ], "loc": { - "end": { - "line": 2, - "column": 41 - }, "start": { "line": 2, "column": 40 + }, + "end": { + "line": 2, + "column": 41 } - }, - "value": "," + } }, { "type": "Identifier", + "value": "readonly", "range": [ 68, 76 ], "loc": { - "end": { - "line": 3, - "column": 22 - }, "start": { "line": 3, "column": 14 + }, + "end": { + "line": 3, + "column": 22 } - }, - "value": "readonly" + } }, { "type": "Identifier", + "value": "lastName", "range": [ 77, 85 ], "loc": { - "end": { - "line": 3, - "column": 31 - }, "start": { "line": 3, "column": 23 + }, + "end": { + "line": 3, + "column": 31 } - }, - "value": "lastName" + } }, { "type": "Punctuator", + "value": ":", "range": [ 85, 86 ], "loc": { - "end": { - "line": 3, - "column": 32 - }, "start": { "line": 3, "column": 31 + }, + "end": { + "line": 3, + "column": 32 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 87, 93 ], "loc": { - "end": { - "line": 3, - "column": 39 - }, "start": { "line": 3, "column": 33 + }, + "end": { + "line": 3, + "column": 39 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": "=", "range": [ 94, 95 ], "loc": { - "end": { - "line": 3, - "column": 41 - }, "start": { "line": 3, "column": 40 + }, + "end": { + "line": 3, + "column": 41 } - }, - "value": "=" + } }, { "type": "String", + "value": "'Smith'", "range": [ 96, 103 ], "loc": { - "end": { - "line": 3, - "column": 49 - }, "start": { "line": 3, "column": 42 + }, + "end": { + "line": 3, + "column": 49 } - }, - "value": "'Smith'" + } }, { "type": "Punctuator", + "value": ")", "range": [ 103, 104 ], "loc": { - "end": { - "line": 3, - "column": 50 - }, "start": { "line": 3, "column": 49 + }, + "end": { + "line": 3, + "column": 50 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": "{", "range": [ 105, 106 ], "loc": { - "end": { - "line": 3, - "column": 52 - }, "start": { "line": 3, "column": 51 + }, + "end": { + "line": 3, + "column": 52 } - }, - "value": "{" + } }, { "type": "Punctuator", + "value": "}", "range": [ 106, 107 ], "loc": { - "end": { - "line": 3, - "column": 53 - }, "start": { "line": 3, "column": 52 + }, + "end": { + "line": 3, + "column": 53 } - }, - "value": "}" + } }, { "type": "Punctuator", + "value": "}", "range": [ 108, 109 ], "loc": { - "end": { - "line": 4, - "column": 1 - }, "start": { "line": 4, "column": 0 + }, + "end": { + "line": 4, + "column": 1 } - }, - "value": "}" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-readonly-property.result.js b/tests/fixtures/typescript/basics/class-with-readonly-property.result.js new file mode 100644 index 0000000..0776637 --- /dev/null +++ b/tests/fixtures/typescript/basics/class-with-readonly-property.result.js @@ -0,0 +1,319 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": "Foo" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "ClassProperty", + "range": [ + 16, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "key": { + "type": "Identifier", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "name": "foo" + }, + "value": { + "type": "Literal", + "range": [ + 38, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "value": "string", + "raw": "'string'" + }, + "computed": false, + "static": false, + "accessibility": "public", + "readonly": true, + "decorators": [], + "typeAnnotation": null + } + ], + "range": [ + 10, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 6, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 10, + 11 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + { + "type": "Keyword", + "value": "public", + "range": [ + 16, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Identifier", + "value": "readonly", + "range": [ + 23, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "String", + "value": "'string'", + "range": [ + 38, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-readonly-property.src.ts b/tests/fixtures/typescript/basics/class-with-readonly-property.src.ts new file mode 100644 index 0000000..feb9657 --- /dev/null +++ b/tests/fixtures/typescript/basics/class-with-readonly-property.src.ts @@ -0,0 +1,3 @@ +class Foo { + public readonly foo = 'string'; +} diff --git a/tests/fixtures/typescript/basics/class-with-static-parameter-properties.result.js b/tests/fixtures/typescript/basics/class-with-static-parameter-properties.result.js index 840e5f5..5ebfa84 100644 --- a/tests/fixtures/typescript/basics/class-with-static-parameter-properties.result.js +++ b/tests/fixtures/typescript/basics/class-with-static-parameter-properties.result.js @@ -464,4 +464,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-type-parameter-default.result.js b/tests/fixtures/typescript/basics/class-with-type-parameter-default.result.js index a86cefb..3e17f6d 100644 --- a/tests/fixtures/typescript/basics/class-with-type-parameter-default.result.js +++ b/tests/fixtures/typescript/basics/class-with-type-parameter-default.result.js @@ -310,4 +310,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-type-parameter-underscore.result.js b/tests/fixtures/typescript/basics/class-with-type-parameter-underscore.result.js index ca918b8..1de1663 100644 --- a/tests/fixtures/typescript/basics/class-with-type-parameter-underscore.result.js +++ b/tests/fixtures/typescript/basics/class-with-type-parameter-underscore.result.js @@ -239,4 +239,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/class-with-type-parameter.result.js b/tests/fixtures/typescript/basics/class-with-type-parameter.result.js index dac4973..d7bee94 100644 --- a/tests/fixtures/typescript/basics/class-with-type-parameter.result.js +++ b/tests/fixtures/typescript/basics/class-with-type-parameter.result.js @@ -239,4 +239,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/declare-class-with-optional-method.result.js b/tests/fixtures/typescript/basics/declare-class-with-optional-method.result.js index d834af4..a31dfd9 100644 --- a/tests/fixtures/typescript/basics/declare-class-with-optional-method.result.js +++ b/tests/fixtures/typescript/basics/declare-class-with-optional-method.result.js @@ -1,393 +1,393 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { + "type": "ClassDeclaration", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": "Foo" + }, "body": { + "type": "ClassBody", "body": [ { - "accessibility": null, - "computed": false, - "decorators": [], - "key": { - "loc": { - "end": { - "column": 7, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } + "type": "MethodDefinition", + "range": [ + 24, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 4 }, - "name": "bar", - "optional": true, + "end": { + "line": 2, + "column": 16 + } + }, + "key": { + "type": "Identifier", "range": [ 24, 27 ], - "type": "Identifier" - }, - "kind": "method", - "loc": { - "end": { - "column": 16, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } }, - "start": { - "column": 4, - "line": 2 - } + "name": "bar", + "optional": true }, - "range": [ - 24, - 36 - ], - "static": false, - "type": "MethodDefinition", "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, "async": false, "body": null, - "expression": false, - "generator": false, - "id": null, - "loc": { - "end": { - "column": 16, - "line": 2 - }, - "start": { - "column": 7, - "line": 2 - } - }, - "params": [], "range": [ 28, 36 ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + }, "returnType": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 15, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 } }, "range": [ 32, 35 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 15, - "line": 2 - }, - "start": { - "column": 12, - "line": 2 - } - }, + "type": "TSAnyKeyword", "range": [ 32, 35 ], - "type": "TSAnyKeyword" + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + } } }, - "type": "FunctionExpression" - } + "params": [] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 18, - "line": 1 - } - }, "range": [ 18, 38 ], - "type": "ClassBody" - }, - "decorators": [], - "id": { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 18 + }, + "end": { + "line": 3, + "column": 1 } - }, - "name": "Foo", - "range": [ - 14, - 17 - ], - "type": "Identifier" - }, - "implements": [], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 } }, - "range": [ - 0, - 38 - ], "superClass": null, - "type": "ClassDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 + "implements": [], + "decorators": [] } - }, - "range": [ - 0, - 38 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 7, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Identifier", + "value": "declare", "range": [ 0, 7 ], - "type": "Identifier", - "value": "declare" - }, - { "loc": { - "end": { - "column": 13, - "line": 1 - }, "start": { - "column": 8, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 } - }, + } + }, + { + "type": "Keyword", + "value": "class", "range": [ 8, 13 ], - "type": "Keyword", - "value": "class" - }, - { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 } - }, + } + }, + { + "type": "Identifier", + "value": "Foo", "range": [ 14, 17 ], - "type": "Identifier", - "value": "Foo" - }, - { "loc": { - "end": { - "column": 19, - "line": 1 - }, "start": { - "column": 18, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 18, 19 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 7, - "line": 2 - }, "start": { - "column": 4, - "line": 2 + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 } - }, + } + }, + { + "type": "Identifier", + "value": "bar", "range": [ 24, 27 ], - "type": "Identifier", - "value": "bar" - }, - { "loc": { - "end": { - "column": 8, - "line": 2 - }, "start": { - "column": 7, - "line": 2 + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 27, 28 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 9, - "line": 2 - }, "start": { - "column": 8, - "line": 2 + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 28, 29 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 10, - "line": 2 - }, "start": { - "column": 9, - "line": 2 + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 29, 30 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 10, - "line": 2 + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 30, 31 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 15, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "any", "range": [ 32, 35 ], - "type": "Identifier", - "value": "any" - }, - { "loc": { - "end": { - "column": 16, - "line": 2 - }, "start": { - "column": 15, - "line": 2 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 35, 36 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 37, 38 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-default-class-with-generic.result.js b/tests/fixtures/typescript/basics/export-default-class-with-generic.result.js index 6b048df..d0c5672 100644 --- a/tests/fixtures/typescript/basics/export-default-class-with-generic.result.js +++ b/tests/fixtures/typescript/basics/export-default-class-with-generic.result.js @@ -33,45 +33,45 @@ module.exports = { "column": 1 } }, - "id": null, "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 20, + 23 + ], "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 20, - "line": 1 + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 21, + 22 + ], "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 } }, "name": "T", - "range": [ - 21, - 22 - ], - "type": "TypeParameter", "constraint": null } - ], - "range": [ - 20, - 23 - ], - "type": "TypeParameterDeclaration" + ] }, + "id": null, "body": { "type": "ClassBody", "body": [], @@ -257,4 +257,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-default-class-with-multiple-generics.result.js b/tests/fixtures/typescript/basics/export-default-class-with-multiple-generics.result.js index e89d715..837c99f 100644 --- a/tests/fixtures/typescript/basics/export-default-class-with-multiple-generics.result.js +++ b/tests/fixtures/typescript/basics/export-default-class-with-multiple-generics.result.js @@ -33,64 +33,64 @@ module.exports = { "column": 1 } }, - "id": null, "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 20, + 26 + ], "loc": { - "end": { - "column": 26, - "line": 1 - }, "start": { - "column": 20, - "line": 1 + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 21, + 22 + ], "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 } }, "name": "T", - "range": [ - 21, - 22 - ], - "type": "TypeParameter", "constraint": null }, { + "type": "TypeParameter", + "range": [ + 24, + 25 + ], "loc": { - "end": { - "column": 25, - "line": 1 - }, "start": { - "column": 24, - "line": 1 + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 } }, "name": "U", - "range": [ - 24, - 25 - ], - "type": "TypeParameter", "constraint": null } - ], - "range": [ - 20, - 26 - ], - "type": "TypeParameterDeclaration" + ] }, + "id": null, "body": { "type": "ClassBody", "body": [], @@ -312,4 +312,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-named-class-with-generic.result.js b/tests/fixtures/typescript/basics/export-named-class-with-generic.result.js index cfbd485..a8d4119 100644 --- a/tests/fixtures/typescript/basics/export-named-class-with-generic.result.js +++ b/tests/fixtures/typescript/basics/export-named-class-with-generic.result.js @@ -33,61 +33,61 @@ module.exports = { "column": 1 } }, - "id": { - "type": "Identifier", + "typeParameters": { + "type": "TypeParameterDeclaration", "range": [ - 13, - 16 + 16, + 19 ], "loc": { "start": { "line": 1, - "column": 13 + "column": 16 }, "end": { "line": 1, - "column": 16 - } - }, - "name": "Foo" - }, - "typeParameters": { - "loc": { - "end": { - "column": 19, - "line": 1 - }, - "start": { - "column": 16, - "line": 1 + "column": 19 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 17, + 18 + ], "loc": { - "end": { - "column": 18, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 } }, "name": "T", - "range": [ - 17, - 18 - ], - "type": "TypeParameter", "constraint": null } - ], + ] + }, + "id": { + "type": "Identifier", "range": [ - 16, - 19 + 13, + 16 ], - "type": "TypeParameterDeclaration" + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "name": "Foo" }, "body": { "type": "ClassBody", @@ -276,4 +276,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-named-class-with-multiple-generics.result.js b/tests/fixtures/typescript/basics/export-named-class-with-multiple-generics.result.js index 0467617..ae3b317 100644 --- a/tests/fixtures/typescript/basics/export-named-class-with-multiple-generics.result.js +++ b/tests/fixtures/typescript/basics/export-named-class-with-multiple-generics.result.js @@ -33,80 +33,80 @@ module.exports = { "column": 1 } }, - "id": { - "type": "Identifier", + "typeParameters": { + "type": "TypeParameterDeclaration", "range": [ - 13, - 16 + 16, + 22 ], "loc": { "start": { "line": 1, - "column": 13 + "column": 16 }, "end": { "line": 1, - "column": 16 - } - }, - "name": "Foo" - }, - "typeParameters": { - "loc": { - "end": { - "column": 22, - "line": 1 - }, - "start": { - "column": 16, - "line": 1 + "column": 22 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 17, + 18 + ], "loc": { - "end": { - "column": 18, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 } }, "name": "T", - "range": [ - 17, - 18 - ], - "type": "TypeParameter", "constraint": null }, { + "type": "TypeParameter", + "range": [ + 20, + 21 + ], "loc": { - "end": { - "column": 21, - "line": 1 - }, "start": { - "column": 20, - "line": 1 + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 } }, "name": "U", - "range": [ - 20, - 21 - ], - "type": "TypeParameter", "constraint": null } - ], + ] + }, + "id": { + "type": "Identifier", "range": [ - 16, - 22 + 13, + 16 ], - "type": "TypeParameterDeclaration" + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "name": "Foo" }, "body": { "type": "ClassBody", @@ -331,4 +331,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-type-alias-declaration.result.js b/tests/fixtures/typescript/basics/export-type-alias-declaration.result.js index 272c62c..cc0f111 100644 --- a/tests/fixtures/typescript/basics/export-type-alias-declaration.result.js +++ b/tests/fixtures/typescript/basics/export-type-alias-declaration.result.js @@ -5,32 +5,18 @@ module.exports = { 40 ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 40 } }, "body": [ { "type": "ExportNamedDeclaration", - "range": [ - 0, - 40 - ], - "loc": { - "end": { - "line": 1, - "column": 40 - }, - "start": { - "line": 1, - "column": 0 - } - }, "declaration": { "type": "VariableDeclaration", "range": [ @@ -38,33 +24,19 @@ module.exports = { 40 ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 1, + "column": 40 } }, "kind": "type", "declarations": [ { "type": "VariableDeclarator", - "range": [ - 12, - 40 - ], - "loc": { - "end": { - "line": 1, - "column": 40 - }, - "start": { - "line": 1, - "column": 12 - } - }, "id": { "type": "Identifier", "range": [ @@ -72,33 +44,33 @@ module.exports = { 21 ], "loc": { - "end": { - "line": 1, - "column": 21 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 21 } }, "name": "TestAlias" }, "init": { "type": "TSUnionType", + "range": [ + 24, + 39 + ], "loc": { - "end": { - "line": 1, - "column": 39 - }, "start": { "line": 1, "column": 24 + }, + "end": { + "line": 1, + "column": 39 } }, - "range": [ - 24, - 39 - ], "types": [ { "type": "TSStringKeyword", @@ -107,13 +79,13 @@ module.exports = { 30 ], "loc": { - "end": { - "line": 1, - "column": 30 - }, "start": { "line": 1, "column": 24 + }, + "end": { + "line": 1, + "column": 30 } } }, @@ -124,170 +96,198 @@ module.exports = { 39 ], "loc": { - "end": { - "line": 1, - "column": 39 - }, "start": { "line": 1, "column": 33 + }, + "end": { + "line": 1, + "column": 39 } } } ] + }, + "range": [ + 12, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 40 + } } } ] }, - "source": null, - "specifiers": [] + "range": [ + 0, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "specifiers": [], + "source": null } ], "sourceType": "module", "tokens": [ { "type": "Keyword", + "value": "export", "range": [ 0, 6 ], "loc": { - "end": { - "line": 1, - "column": 6 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 6 } - }, - "value": "export" + } }, { "type": "Identifier", + "value": "type", "range": [ 7, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "type" + } }, { "type": "Identifier", + "value": "TestAlias", "range": [ 12, 21 ], "loc": { - "end": { - "line": 1, - "column": 21 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 21 } - }, - "value": "TestAlias" + } }, { "type": "Punctuator", + "value": "=", "range": [ 22, 23 ], "loc": { - "end": { - "line": 1, - "column": 23 - }, "start": { "line": 1, "column": 22 + }, + "end": { + "line": 1, + "column": 23 } - }, - "value": "=" + } }, { "type": "Identifier", + "value": "string", "range": [ 24, 30 ], "loc": { - "end": { - "line": 1, - "column": 30 - }, "start": { "line": 1, "column": 24 + }, + "end": { + "line": 1, + "column": 30 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": "|", "range": [ 31, 32 ], "loc": { - "end": { - "line": 1, - "column": 32 - }, "start": { "line": 1, "column": 31 + }, + "end": { + "line": 1, + "column": 32 } - }, - "value": "|" + } }, { "type": "Identifier", + "value": "number", "range": [ 33, 39 ], "loc": { - "end": { - "line": 1, - "column": 39 - }, "start": { "line": 1, "column": 33 + }, + "end": { + "line": 1, + "column": 39 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": ";", "range": [ 39, 40 ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 39 + }, + "end": { + "line": 1, + "column": 40 } - }, - "value": ";" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-type-class-declaration.result.js b/tests/fixtures/typescript/basics/export-type-class-declaration.result.js index 94b16ab..1aea65b 100644 --- a/tests/fixtures/typescript/basics/export-type-class-declaration.result.js +++ b/tests/fixtures/typescript/basics/export-type-class-declaration.result.js @@ -5,32 +5,18 @@ module.exports = { 51 ], "loc": { - "end": { - "line": 3, - "column": 2 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 3, + "column": 2 } }, "body": [ { "type": "ExportNamedDeclaration", - "range": [ - 0, - 51 - ], - "loc": { - "end": { - "line": 3, - "column": 2 - }, - "start": { - "line": 1, - "column": 0 - } - }, "declaration": { "type": "VariableDeclaration", "range": [ @@ -38,33 +24,19 @@ module.exports = { 51 ], "loc": { - "end": { - "line": 3, - "column": 2 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 3, + "column": 2 } }, "kind": "type", "declarations": [ { "type": "VariableDeclarator", - "range": [ - 12, - 51 - ], - "loc": { - "end": { - "line": 3, - "column": 2 - }, - "start": { - "line": 1, - "column": 12 - } - }, "id": { "type": "Identifier", "range": [ @@ -72,13 +44,13 @@ module.exports = { 26 ], "loc": { - "end": { - "line": 1, - "column": 26 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 26 } }, "name": "TestClassProps" @@ -90,13 +62,13 @@ module.exports = { 50 ], "loc": { - "end": { - "line": 3, - "column": 1 - }, "start": { "line": 1, "column": 29 + }, + "end": { + "line": 3, + "column": 1 } }, "members": [ @@ -177,195 +149,223 @@ module.exports = { "export": false } ] + }, + "range": [ + 12, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 2 + } } } ] }, - "source": null, - "specifiers": [] + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "specifiers": [], + "source": null } ], "sourceType": "module", "tokens": [ { "type": "Keyword", + "value": "export", "range": [ 0, 6 ], "loc": { - "end": { - "line": 1, - "column": 6 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 6 } - }, - "value": "export" + } }, { "type": "Identifier", + "value": "type", "range": [ 7, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "type" + } }, { "type": "Identifier", + "value": "TestClassProps", "range": [ 12, 26 ], "loc": { - "end": { - "line": 1, - "column": 26 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 26 } - }, - "value": "TestClassProps" + } }, { "type": "Punctuator", + "value": "=", "range": [ 27, 28 ], "loc": { - "end": { - "line": 1, - "column": 28 - }, "start": { "line": 1, "column": 27 + }, + "end": { + "line": 1, + "column": 28 } - }, - "value": "=" + } }, { "type": "Punctuator", + "value": "{", "range": [ 29, 30 ], "loc": { - "end": { - "line": 1, - "column": 30 - }, "start": { "line": 1, "column": 29 + }, + "end": { + "line": 1, + "column": 30 } - }, - "value": "{" + } }, { "type": "Identifier", + "value": "count", "range": [ 35, 40 ], "loc": { - "end": { - "line": 2, - "column": 9 - }, "start": { "line": 2, "column": 4 + }, + "end": { + "line": 2, + "column": 9 } - }, - "value": "count" + } }, { "type": "Punctuator", + "value": ":", "range": [ 40, 41 ], "loc": { - "end": { - "line": 2, - "column": 10 - }, "start": { "line": 2, "column": 9 + }, + "end": { + "line": 2, + "column": 10 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "number", "range": [ 42, 48 ], "loc": { - "end": { - "line": 2, - "column": 17 - }, "start": { "line": 2, "column": 11 + }, + "end": { + "line": 2, + "column": 17 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": "}", "range": [ 49, 50 ], "loc": { - "end": { - "line": 3, - "column": 1 - }, "start": { "line": 3, "column": 0 + }, + "end": { + "line": 3, + "column": 1 } - }, - "value": "}" + } }, { "type": "Punctuator", + "value": ";", "range": [ 50, 51 ], "loc": { - "end": { - "line": 3, - "column": 2 - }, "start": { "line": 3, "column": 1 + }, + "end": { + "line": 3, + "column": 2 } - }, - "value": ";" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/export-type-function-declaration.result.js b/tests/fixtures/typescript/basics/export-type-function-declaration.result.js index 92f1829..cbae7e5 100644 --- a/tests/fixtures/typescript/basics/export-type-function-declaration.result.js +++ b/tests/fixtures/typescript/basics/export-type-function-declaration.result.js @@ -5,32 +5,18 @@ module.exports = { 47 ], "loc": { - "end": { - "line": 1, - "column": 47 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 47 } }, "body": [ { "type": "ExportNamedDeclaration", - "range": [ - 0, - 47 - ], - "loc": { - "end": { - "line": 1, - "column": 47 - }, - "start": { - "line": 1, - "column": 0 - } - }, "declaration": { "type": "VariableDeclaration", "range": [ @@ -38,33 +24,19 @@ module.exports = { 47 ], "loc": { - "end": { - "line": 1, - "column": 47 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 1, + "column": 47 } }, "kind": "type", "declarations": [ { "type": "VariableDeclarator", - "range": [ - 12, - 47 - ], - "loc": { - "end": { - "line": 1, - "column": 47 - }, - "start": { - "line": 1, - "column": 12 - } - }, "id": { "type": "Identifier", "range": [ @@ -72,13 +44,13 @@ module.exports = { 24 ], "loc": { - "end": { - "line": 1, - "column": 24 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 24 } }, "name": "TestCallback" @@ -90,13 +62,13 @@ module.exports = { 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 27 + }, + "end": { + "line": 1, + "column": 46 } }, "typeParameters": null, @@ -108,32 +80,32 @@ module.exports = { 29 ], "loc": { - "end": { - "line": 1, - "column": 29 - }, "start": { "line": 1, "column": 28 + }, + "end": { + "line": 1, + "column": 29 } }, "name": "a", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 31, - 37 - ], "loc": { - "end": { - "line": 1, - "column": 37 - }, "start": { "line": 1, "column": 31 + }, + "end": { + "line": 1, + "column": 37 } }, + "range": [ + 31, + 37 + ], "typeAnnotation": { "type": "TSNumberKeyword", "range": [ @@ -141,13 +113,13 @@ module.exports = { 37 ], "loc": { - "end": { - "line": 1, - "column": 37 - }, "start": { "line": 1, "column": 31 + }, + "end": { + "line": 1, + "column": 37 } } } @@ -156,20 +128,20 @@ module.exports = { ], "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 42, - 46 - ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 42 + }, + "end": { + "line": 1, + "column": 46 } }, + "range": [ + 42, + 46 + ], "typeAnnotation": { "type": "TSVoidKeyword", "range": [ @@ -177,242 +149,270 @@ module.exports = { 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 42 + }, + "end": { + "line": 1, + "column": 46 } } } } + }, + "range": [ + 12, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 47 + } } } ] }, - "source": null, - "specifiers": [] + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "specifiers": [], + "source": null } ], "sourceType": "module", "tokens": [ { "type": "Keyword", + "value": "export", "range": [ 0, 6 ], "loc": { - "end": { - "line": 1, - "column": 6 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 6 } - }, - "value": "export" + } }, { "type": "Identifier", + "value": "type", "range": [ 7, 11 ], "loc": { - "end": { - "line": 1, - "column": 11 - }, "start": { "line": 1, "column": 7 + }, + "end": { + "line": 1, + "column": 11 } - }, - "value": "type" + } }, { "type": "Identifier", + "value": "TestCallback", "range": [ 12, 24 ], "loc": { - "end": { - "line": 1, - "column": 24 - }, "start": { "line": 1, "column": 12 + }, + "end": { + "line": 1, + "column": 24 } - }, - "value": "TestCallback" + } }, { "type": "Punctuator", + "value": "=", "range": [ 25, 26 ], "loc": { - "end": { - "line": 1, - "column": 26 - }, "start": { "line": 1, "column": 25 + }, + "end": { + "line": 1, + "column": 26 } - }, - "value": "=" + } }, { "type": "Punctuator", + "value": "(", "range": [ 27, 28 ], "loc": { - "end": { - "line": 1, - "column": 28 - }, "start": { "line": 1, "column": 27 + }, + "end": { + "line": 1, + "column": 28 } - }, - "value": "(" + } }, { "type": "Identifier", + "value": "a", "range": [ 28, 29 ], "loc": { - "end": { - "line": 1, - "column": 29 - }, "start": { "line": 1, "column": 28 + }, + "end": { + "line": 1, + "column": 29 } - }, - "value": "a" + } }, { "type": "Punctuator", + "value": ":", "range": [ 29, 30 ], "loc": { - "end": { - "line": 1, - "column": 30 - }, "start": { "line": 1, "column": 29 + }, + "end": { + "line": 1, + "column": 30 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "number", "range": [ 31, 37 ], "loc": { - "end": { - "line": 1, - "column": 37 - }, "start": { "line": 1, "column": 31 + }, + "end": { + "line": 1, + "column": 37 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": ")", "range": [ 37, 38 ], "loc": { - "end": { - "line": 1, - "column": 38 - }, "start": { "line": 1, "column": 37 + }, + "end": { + "line": 1, + "column": 38 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": "=>", "range": [ 39, 41 ], "loc": { - "end": { - "line": 1, - "column": 41 - }, "start": { "line": 1, "column": 39 + }, + "end": { + "line": 1, + "column": 41 } - }, - "value": "=>" + } }, { "type": "Keyword", + "value": "void", "range": [ 42, 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 42 + }, + "end": { + "line": 1, + "column": 46 } - }, - "value": "void" + } }, { "type": "Punctuator", + "value": ";", "range": [ 46, 47 ], "loc": { - "end": { - "line": 1, - "column": 47 - }, "start": { "line": 1, "column": 46 + }, + "end": { + "line": 1, + "column": 47 } - }, - "value": ";" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-await.result.js b/tests/fixtures/typescript/basics/function-with-await.result.js index f9e54ea..a4f575c 100644 --- a/tests/fixtures/typescript/basics/function-with-await.result.js +++ b/tests/fixtures/typescript/basics/function-with-await.result.js @@ -1,349 +1,349 @@ module.exports = { "type": "Program", + "range": [ + 0, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { "type": "FunctionDeclaration", - "expression": false, - "generator": false, - "async": true, + "range": [ + 0, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "id": { "type": "Identifier", - "name": "hope", + "range": [ + 15, + 19 + ], "loc": { - "end": { - "column": 19, - "line": 1 - }, "start": { - "column": 15, - "line": 1 + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 } }, - "range": [ - 15, - 19 - ] + "name": "hope" }, + "generator": false, + "expression": false, + "async": true, "params": [ { - "loc": { - "end": { - "column": 26, - "line": 1 - }, - "start": { - "column": 20, - "line": 1 - } - }, - "name": "future", + "type": "Identifier", "range": [ 20, 26 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": "future" } ], "body": { "type": "BlockStatement", + "range": [ + 28, + 49 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { "type": "ExpressionStatement", + "range": [ + 34, + 47 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + } + }, "expression": { "type": "AwaitExpression", + "range": [ + 34, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, "argument": { "type": "Identifier", - "loc": { - "end": { - "column": 16, - "line": 2 - }, - "start": { - "column": 10, - "line": 2 - } - }, - "name": "future", "range": [ 40, 46 - ] - }, - "loc": { - "end": { - "column": 16, - "line": 2 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 16 + } }, - "start": { - "column": 4, - "line": 2 - } - }, - "range": [ - 34, - 46 - ] - }, - "loc": { - "end": { - "column": 17, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 + "name": "future" } - }, - "range": [ - 34, - 47 - ] - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 28, - "line": 1 + } } - }, - "range": [ - 28, - 49 ] - }, - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 49 - ] - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 + } } - }, - "range": [ - 0, - 49 ], "sourceType": "script", "tokens": [ { "type": "Identifier", "value": "async", - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, "range": [ 0, 5 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } }, { "type": "Keyword", "value": "function", - "loc": { - "end": { - "column": 14, - "line": 1 - }, - "start": { - "column": 6, - "line": 1 - } - }, "range": [ 6, 14 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + } }, { "type": "Identifier", "value": "hope", - "loc": { - "end": { - "column": 19, - "line": 1 - }, - "start": { - "column": 15, - "line": 1 - } - }, "range": [ 15, 19 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + } }, { "type": "Punctuator", "value": "(", - "loc": { - "end": { - "column": 20, - "line": 1 - }, - "start": { - "column": 19, - "line": 1 - } - }, "range": [ 19, 20 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } }, { "type": "Identifier", "value": "future", - "loc": { - "end": { - "column": 26, - "line": 1 - }, - "start": { - "column": 20, - "line": 1 - } - }, "range": [ 20, 26 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 + } + } }, { "type": "Punctuator", "value": ")", - "loc": { - "end": { - "column": 27, - "line": 1 - }, - "start": { - "column": 26, - "line": 1 - } - }, "range": [ 26, 27 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + } }, { "type": "Punctuator", "value": "{", - "loc": { - "end": { - "column": 29, - "line": 1 - }, - "start": { - "column": 28, - "line": 1 - } - }, "range": [ 28, 29 - ] + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + } }, { "type": "Identifier", "value": "await", - "loc": { - "end": { - "column": 9, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } - }, "range": [ 34, 39 - ] + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + } }, { "type": "Identifier", "value": "future", - "loc": { - "end": { - "column": 16, - "line": 2 - }, - "start": { - "column": 10, - "line": 2 - } - }, "range": [ 40, 46 - ] + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 16 + } + } }, { "type": "Punctuator", "value": ";", - "loc": { - "end": { - "column": 17, - "line": 2 - }, - "start": { - "column": 16, - "line": 2 - } - }, "range": [ 46, 47 - ] + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } }, { "type": "Punctuator", "value": "}", - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 3 - } - }, "range": [ 48, 49 - ] + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-object-type-with-optional-properties.result.js b/tests/fixtures/typescript/basics/function-with-object-type-with-optional-properties.result.js index de960f1..71cb2fa 100644 --- a/tests/fixtures/typescript/basics/function-with-object-type-with-optional-properties.result.js +++ b/tests/fixtures/typescript/basics/function-with-object-type-with-optional-properties.result.js @@ -1,213 +1,220 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { - "async": false, - "body": { - "body": [], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 47, - "line": 1 - } + "type": "FunctionDeclaration", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - "range": [ - 47, - 51 - ], - "type": "BlockStatement" + "end": { + "line": 3, + "column": 1 + } }, - "expression": false, - "generator": false, "id": { - "loc": { - "end": { - "column": 12, - "line": 1 - }, - "start": { - "column": 9, - "line": 1 - } - }, - "name": "foo", + "type": "Identifier", "range": [ 9, 12 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 1, - "line": 3 + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } }, - "start": { - "column": 0, - "line": 1 - } + "name": "foo" }, + "generator": false, + "expression": false, + "async": false, "params": [ { + "type": "ObjectPattern", + "range": [ + 13, + 23 + ], "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 13, - "line": 1 + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 23 } }, "properties": [ { - "computed": false, - "key": { - "loc": { - "end": { - "column": 17, - "line": 1 - }, - "start": { - "column": 14, - "line": 1 - } + "type": "Property", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 14 }, - "name": "bar", + "end": { + "line": 1, + "column": 17 + } + }, + "key": { + "type": "Identifier", "range": [ 14, 17 ], - "type": "Identifier" - }, - "kind": "init", - "loc": { - "end": { - "column": 17, - "line": 1 - }, - "start": { - "column": 14, - "line": 1 - } - }, - "method": false, - "range": [ - 14, - 17 - ], - "shorthand": true, - "type": "Property", - "value": { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 } }, - "name": "bar", + "name": "bar" + }, + "value": { + "type": "Identifier", "range": [ 14, 17 ], - "type": "Identifier" - } - }, - { - "computed": false, - "key": { "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 19, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 } }, - "name": "baz", - "range": [ - 19, - 22 - ], - "type": "Identifier" - }, - "kind": "init", - "loc": { - "end": { - "column": 22, - "line": 1 - }, - "start": { - "column": 19, - "line": 1 - } + "name": "bar" }, + "computed": false, "method": false, + "shorthand": true, + "kind": "init" + }, + { + "type": "Property", "range": [ 19, 22 ], - "shorthand": true, - "type": "Property", - "value": { + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "key": { + "type": "Identifier", + "range": [ + 19, + 22 + ], "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 19, - "line": 1 + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 } }, - "name": "baz", + "name": "baz" + }, + "value": { + "type": "Identifier", "range": [ 19, 22 ], - "type": "Identifier" - } + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "name": "baz" + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" } ], - "range": [ - 13, - 23 - ], - "type": "ObjectPattern", "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 45, - "line": 1 - }, "start": { - "column": 25, - "line": 1 + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 45 } }, "range": [ 25, 45 ], - "type": "TypeAnnotation", "typeAnnotation": { + "type": "TSTypeLiteral", + "range": [ + 25, + 45 + ], "loc": { - "end": { - "column": 45, - "line": 1 - }, "start": { - "column": 25, - "line": 1 + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 45 } }, "members": [ @@ -330,417 +337,410 @@ module.exports = { "static": false, "export": false } - ], - "range": [ - 25, - 45 - ], - "type": "TSTypeLiteral" + ] } } } ], - "range": [ - 0, - 51 - ], - "type": "FunctionDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 + "body": { + "type": "BlockStatement", + "range": [ + 47, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [] + } } - }, - "range": [ - 0, - 51 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 8, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "function", "range": [ 0, 8 ], - "type": "Keyword", - "value": "function" - }, - { "loc": { - "end": { - "column": 12, - "line": 1 - }, "start": { - "column": 9, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 } - }, + } + }, + { + "type": "Identifier", + "value": "foo", "range": [ 9, 12 ], - "type": "Identifier", - "value": "foo" - }, - { "loc": { - "end": { - "column": 13, - "line": 1 - }, "start": { - "column": 12, - "line": 1 + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 12, 13 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 14, - "line": 1 - }, "start": { - "column": 13, - "line": 1 + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 13, 14 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 } - }, + } + }, + { + "type": "Identifier", + "value": "bar", "range": [ 14, 17 ], - "type": "Identifier", - "value": "bar" - }, - { "loc": { - "end": { - "column": 18, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 } - }, + } + }, + { + "type": "Punctuator", + "value": ",", "range": [ 17, 18 ], - "type": "Punctuator", - "value": "," - }, - { "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 19, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 } - }, + } + }, + { + "type": "Identifier", + "value": "baz", "range": [ 19, 22 ], - "type": "Identifier", - "value": "baz" - }, - { "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 22, 23 ], - "type": "Punctuator", - "value": "}" - }, - { "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 23, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 23, 24 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 26, - "line": 1 - }, "start": { - "column": 25, - "line": 1 + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 25, 26 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 29, - "line": 1 - }, "start": { - "column": 26, - "line": 1 + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 } - }, + } + }, + { + "type": "Identifier", + "value": "bar", "range": [ 26, 29 ], - "type": "Identifier", - "value": "bar" - }, - { "loc": { - "end": { - "column": 30, - "line": 1 - }, "start": { - "column": 29, - "line": 1 + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 29 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 29, 30 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 31, - "line": 1 - }, "start": { - "column": 30, - "line": 1 + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 30, 31 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 32, - "line": 1 + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 32, 38 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 39, - "line": 1 - }, "start": { - "column": 38, - "line": 1 + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 } - }, + } + }, + { + "type": "Punctuator", + "value": ",", "range": [ 38, 39 ], - "type": "Punctuator", - "value": "," - }, - { "loc": { - "end": { - "column": 43, - "line": 1 - }, "start": { - "column": 40, - "line": 1 + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 } - }, + } + }, + { + "type": "Identifier", + "value": "baz", "range": [ 40, 43 ], - "type": "Identifier", - "value": "baz" - }, - { "loc": { - "end": { - "column": 44, - "line": 1 - }, "start": { - "column": 43, - "line": 1 + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 43 } - }, + } + }, + { + "type": "Punctuator", + "value": "?", "range": [ 43, 44 ], - "type": "Punctuator", - "value": "?" - }, - { "loc": { - "end": { - "column": 45, - "line": 1 - }, "start": { - "column": 44, - "line": 1 + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 44, 45 ], - "type": "Punctuator", - "value": "}" - }, - { "loc": { - "end": { - "column": 46, - "line": 1 - }, "start": { - "column": 45, - "line": 1 + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 45, 46 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 48, - "line": 1 - }, "start": { - "column": 47, - "line": 1 + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 46 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 47, 48 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 50, 51 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-object-type-without-annotation.result.js b/tests/fixtures/typescript/basics/function-with-object-type-without-annotation.result.js index a964436..07e565f 100644 --- a/tests/fixtures/typescript/basics/function-with-object-type-without-annotation.result.js +++ b/tests/fixtures/typescript/basics/function-with-object-type-without-annotation.result.js @@ -707,4 +707,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.result.js b/tests/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.result.js index bf99910..6b925ea 100644 --- a/tests/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.result.js +++ b/tests/fixtures/typescript/basics/function-with-type-parameters-that-have-comments.result.js @@ -1,229 +1,279 @@ module.exports = { - body: [{ - async: false, - body: { - body: [], - loc: { - end: { - column: 35, - line: 1 - }, - start: { - column: 33, - line: 1 - } - }, - range: [33, 35], - type: "BlockStatement" + "type": "Program", + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - expression: false, - generator: false, - id: { - loc: { - end: { - column: 16, - line: 1 + "end": { + "line": 1, + "column": 35 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - start: { - column: 9, - line: 1 + "end": { + "line": 1, + "column": 35 } }, - name: "compare", - range: [9, 16], - type: "Identifier" - }, - loc: { - end: { - column: 35, - line: 1 + "id": { + "type": "Identifier", + "range": [ + 9, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "name": "compare" }, - start: { - column: 0, - line: 1 - } - }, - params: [], - range: [0, 35], - type: "FunctionDeclaration", - typeParameters: { - loc: { - end: { - column: 30, - line: 1 + "generator": false, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "range": [ + 33, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } }, - start: { - column: 16, - line: 1 - } + "body": [] }, - params: [{ - constraint: null, - loc: { - end: { - column: 29, - line: 1 + "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 16, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 16 }, - start: { - column: 28, - line: 1 + "end": { + "line": 1, + "column": 30 } }, - name: "T", - range: [28, 29], - type: "TypeParameter" - }], - range: [16, 30], - type: "TypeParameterDeclaration" - } - }], - loc: { - end: { - column: 35, - line: 1 - }, - start: { - column: 0, - line: 1 + "params": [ + { + "type": "TypeParameter", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": "T", + "constraint": null + } + ] + } } - }, - range: [0, 35], - sourceType: "script", - tokens: [{ - loc: { - end: { - column: 8, - line: 1 + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "function", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - start: { - column: 0, - line: 1 + "end": { + "line": 1, + "column": 8 } - }, - range: [0, 8], - type: "Keyword", - value: "function" + } }, { - loc: { - end: { - column: 16, - line: 1 + "type": "Identifier", + "value": "compare", + "range": [ + 9, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 9 }, - start: { - column: 9, - line: 1 + "end": { + "line": 1, + "column": 16 } - }, - range: [9, 16], - type: "Identifier", - value: "compare" + } }, { - loc: { - end: { - column: 17, - line: 1 + "type": "Punctuator", + "value": "<", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 16 }, - start: { - column: 16, - line: 1 + "end": { + "line": 1, + "column": 17 } - }, - range: [16, 17], - type: "Punctuator", - value: "<" + } }, { - loc: { - end: { - column: 29, - line: 1 + "type": "Identifier", + "value": "T", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 28 }, - start: { - column: 28, - line: 1 + "end": { + "line": 1, + "column": 29 } - }, - range: [28, 29], - type: "Identifier", - value: "T" + } }, { - loc: { - end: { - column: 30, - line: 1 + "type": "Punctuator", + "value": ">", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 29 }, - start: { - column: 29, - line: 1 + "end": { + "line": 1, + "column": 30 } - }, - range: [29, 30], - type: "Punctuator", - value: ">" + } }, { - loc: { - end: { - column: 31, - line: 1 + "type": "Punctuator", + "value": "(", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 30 }, - start: { - column: 30, - line: 1 + "end": { + "line": 1, + "column": 31 } - }, - range: [30, 31], - type: "Punctuator", - value: "(" + } }, { - loc: { - end: { - column: 32, - line: 1 + "type": "Punctuator", + "value": ")", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 }, - start: { - column: 31, - line: 1 + "end": { + "line": 1, + "column": 32 } - }, - range: [31, 32], - type: "Punctuator", - value: ")" + } }, { - loc: { - end: { - column: 34, - line: 1 + "type": "Punctuator", + "value": "{", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 }, - start: { - column: 33, - line: 1 + "end": { + "line": 1, + "column": 34 } - }, - range: [33, 34], - type: "Punctuator", - value: "{" + } }, { - loc: { - end: { - column: 35, - line: 1 + "type": "Punctuator", + "value": "}", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 }, - start: { - column: 34, - line: 1 + "end": { + "line": 1, + "column": 35 } - }, - range: [34, 35], - type: "Punctuator", - value: "}" + } } - ], - type: "Program" + ] }; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-type-parameters-with-constraint.result.js b/tests/fixtures/typescript/basics/function-with-type-parameters-with-constraint.result.js index e212335..1e7df8c 100644 --- a/tests/fixtures/typescript/basics/function-with-type-parameters-with-constraint.result.js +++ b/tests/fixtures/typescript/basics/function-with-type-parameters-with-constraint.result.js @@ -1,670 +1,670 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { - "async": false, - "body": { - "body": [ - { - "argument": { - "loc": { - "end": { - "column": 12, - "line": 2 - }, - "start": { - "column": 11, - "line": 2 - } - }, - "name": "b", - "range": [ - 47, - 48 - ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 13, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } - }, - "range": [ - 40, - 49 - ], - "type": "ReturnStatement" - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 34, - "line": 1 - } + "type": "FunctionDeclaration", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - "range": [ - 34, - 51 - ], - "type": "BlockStatement" + "end": { + "line": 3, + "column": 1 + } }, - "expression": false, - "generator": false, "id": { - "loc": { - "end": { - "column": 10, - "line": 1 - }, - "start": { - "column": 9, - "line": 1 - } - }, - "name": "a", + "type": "Identifier", "range": [ 9, 10 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 1, - "line": 3 + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } }, - "start": { - "column": 0, - "line": 1 - } + "name": "a" }, + "generator": false, + "expression": false, + "async": false, "params": [ { + "type": "Identifier", + "range": [ + 25, + 26 + ], "loc": { - "end": { - "column": 26, - "line": 1 - }, "start": { - "column": 25, - "line": 1 + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 } }, "name": "b", - "range": [ - 25, - 26 - ], - "type": "Identifier", "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 29, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 } }, "range": [ 28, 29 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 29, - "line": 1 - }, - "start": { - "column": 28, - "line": 1 - } - }, + "type": "TSTypeReference", "range": [ 28, 29 ], - "type": "TSTypeReference", - "typeName": { - "loc": { - "end": { - "column": 29, - "line": 1 - }, - "start": { - "column": 28, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 28 }, - "name": "X", + "end": { + "line": 1, + "column": 29 + } + }, + "typeName": { + "type": "Identifier", "range": [ 28, 29 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": "X" } } } } ], - "range": [ - 0, - 51 - ], - "returnType": { + "body": { + "type": "BlockStatement", + "range": [ + 34, + 51 + ], "loc": { - "end": { - "column": 33, - "line": 1 + "start": { + "line": 1, + "column": 34 }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ReturnStatement", + "range": [ + 40, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "argument": { + "type": "Identifier", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "b" + } + } + ] + }, + "returnType": { + "type": "TypeAnnotation", + "loc": { "start": { - "column": 32, - "line": 1 + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 } }, "range": [ 32, 33 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 33, - "line": 1 - }, - "start": { - "column": 32, - "line": 1 - } - }, + "type": "TSTypeReference", "range": [ 32, 33 ], - "type": "TSTypeReference", - "typeName": { - "loc": { - "end": { - "column": 33, - "line": 1 - }, - "start": { - "column": 32, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 32 }, - "name": "X", + "end": { + "line": 1, + "column": 33 + } + }, + "typeName": { + "type": "Identifier", "range": [ 32, 33 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "name": "X" } } }, - "type": "FunctionDeclaration", "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 10, + 24 + ], "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 24 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 11, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": "X", "constraint": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 } }, "range": [ 21, 23 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 23, - "line": 1 - }, - "start": { - "column": 21, - "line": 1 - } - }, - "members": [], + "type": "TSTypeLiteral", "range": [ 21, 23 ], - "type": "TSTypeLiteral" - } - }, - "loc": { - "end": { - "column": 23, - "line": 1 - }, - "start": { - "column": 11, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "members": [] } - }, - "name": "X", - "range": [ - 11, - 23 - ], - "type": "TypeParameter" + } } - ], - "range": [ - 10, - 24 - ], - "type": "TypeParameterDeclaration" + ] } } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 51 - ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 8, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "function", "range": [ 0, 8 ], - "type": "Keyword", - "value": "function" - }, - { "loc": { - "end": { - "column": 10, - "line": 1 - }, "start": { - "column": 9, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 } - }, + } + }, + { + "type": "Identifier", + "value": "a", "range": [ 9, 10 ], - "type": "Identifier", - "value": "a" - }, - { "loc": { - "end": { - "column": 11, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 10, 11 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 12, - "line": 1 - }, "start": { - "column": 11, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "X", "range": [ 11, 12 ], - "type": "Identifier", - "value": "X" - }, - { "loc": { - "end": { - "column": 20, - "line": 1 - }, "start": { - "column": 13, - "line": 1 + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 } - }, + } + }, + { + "type": "Keyword", + "value": "extends", "range": [ 13, 20 ], - "type": "Keyword", - "value": "extends" - }, - { "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 21, 22 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 22, 23 ], - "type": "Punctuator", - "value": "}" - }, - { "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 23, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 23, 24 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 25, - "line": 1 - }, "start": { - "column": 24, - "line": 1 + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 24, 25 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 26, - "line": 1 - }, "start": { - "column": 25, - "line": 1 + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 } - }, + } + }, + { + "type": "Identifier", + "value": "b", "range": [ 25, 26 ], - "type": "Identifier", - "value": "b" - }, - { "loc": { - "end": { - "column": 27, - "line": 1 - }, "start": { - "column": 26, - "line": 1 + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 26, 27 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 29, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 } - }, + } + }, + { + "type": "Identifier", + "value": "X", "range": [ 28, 29 ], - "type": "Identifier", - "value": "X" - }, - { "loc": { - "end": { - "column": 30, - "line": 1 - }, "start": { - "column": 29, - "line": 1 + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 29, 30 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 31, - "line": 1 - }, "start": { - "column": 30, - "line": 1 + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 30, 31 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 33, - "line": 1 - }, "start": { - "column": 32, - "line": 1 + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 } - }, + } + }, + { + "type": "Identifier", + "value": "X", "range": [ 32, 33 ], - "type": "Identifier", - "value": "X" - }, - { "loc": { - "end": { - "column": 35, - "line": 1 - }, "start": { - "column": 34, - "line": 1 + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 34, 35 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 10, - "line": 2 - }, "start": { - "column": 4, - "line": 2 + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 } - }, + } + }, + { + "type": "Keyword", + "value": "return", "range": [ 40, 46 ], - "type": "Keyword", - "value": "return" - }, - { "loc": { - "end": { - "column": 12, - "line": 2 - }, "start": { - "column": 11, - "line": 2 + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 } - }, + } + }, + { + "type": "Identifier", + "value": "b", "range": [ 47, 48 ], - "type": "Identifier", - "value": "b" - }, - { "loc": { - "end": { - "column": 13, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 48, 49 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 50, 51 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-type-parameters.result.js b/tests/fixtures/typescript/basics/function-with-type-parameters.result.js index 6263e61..1eb5405 100644 --- a/tests/fixtures/typescript/basics/function-with-type-parameters.result.js +++ b/tests/fixtures/typescript/basics/function-with-type-parameters.result.js @@ -579,4 +579,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/function-with-types-assignation.result.js b/tests/fixtures/typescript/basics/function-with-types-assignation.result.js index 0a1f4f5..f6383af 100644 --- a/tests/fixtures/typescript/basics/function-with-types-assignation.result.js +++ b/tests/fixtures/typescript/basics/function-with-types-assignation.result.js @@ -5,74 +5,32 @@ module.exports = { 96 ], "loc": { - "end": { - "line": 3, - "column": 1 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 3, + "column": 1 } }, "body": [ { - "async": false, - "body": { - "body": [ - { - "argument": { - "type": "Identifier", - "range": [ - 89, - 93 - ], - "loc": { - "end": { - "line": 2, - "column": 13 - }, - "start": { - "line": 2, - "column": 9 - } - }, - "name": "name" - }, - "type": "ReturnStatement", - "range": [ - 82, - 94 - ], - "loc": { - "end": { - "line": 2, - "column": 14 - }, - "start": { - "line": 2, - "column": 2 - } - } - } - ], - "type": "BlockStatement", - "range": [ - 78, - 96 - ], - "loc": { - "end": { - "line": 3, - "column": 1 - }, - "start": { - "line": 1, - "column": 78 - } + "type": "FunctionDeclaration", + "range": [ + 0, + 96 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 } }, - "expression": false, - "generator": false, "id": { "type": "Identifier", "range": [ @@ -80,66 +38,54 @@ module.exports = { 16 ], "loc": { - "end": { - "line": 1, - "column": 16 - }, "start": { "line": 1, "column": 9 + }, + "end": { + "line": 1, + "column": 16 } }, "name": "message" }, - "type": "FunctionDeclaration", - "range": [ - 0, - 96 - ], - "loc": { - "end": { - "line": 3, - "column": 1 - }, - "start": { - "line": 1, - "column": 0 - } - }, + "generator": false, + "expression": false, + "async": false, "params": [ { + "type": "Identifier", + "range": [ + 17, + 21 + ], "loc": { - "end": { - "line": 1, - "column": 21 - }, "start": { "line": 1, "column": 17 + }, + "end": { + "line": 1, + "column": 21 } }, "name": "name", - "range": [ - 17, - 21 - ], - "type": "Identifier", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 22, - 28 - ], "loc": { - "end": { - "line": 1, - "column": 28 - }, "start": { "line": 1, "column": 22 + }, + "end": { + "line": 1, + "column": 28 } }, + "range": [ + 22, + 28 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -147,13 +93,13 @@ module.exports = { 28 ], "loc": { - "end": { - "line": 1, - "column": 28 - }, "start": { "line": 1, "column": 22 + }, + "end": { + "line": 1, + "column": 28 } } } @@ -166,13 +112,13 @@ module.exports = { 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 30 + }, + "end": { + "line": 1, + "column": 46 } }, "left": { @@ -182,32 +128,32 @@ module.exports = { 33 ], "loc": { - "end": { - "line": 1, - "column": 33 - }, "start": { "line": 1, "column": 30 + }, + "end": { + "line": 1, + "column": 33 } }, "name": "age", "typeAnnotation": { "type": "TypeAnnotation", - "range": [ - 34, - 40 - ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 34 + }, + "end": { + "line": 1, + "column": 40 } }, + "range": [ + 34, + 40 + ], "typeAnnotation": { "type": "TSNumberKeyword", "range": [ @@ -215,13 +161,13 @@ module.exports = { 40 ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 34 + }, + "end": { + "line": 1, + "column": 40 } } } @@ -234,178 +180,231 @@ module.exports = { 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 43 + }, + "end": { + "line": 1, + "column": 46 } }, - "raw": "100", - "value": 100 + "value": 100, + "raw": "100" } }, { + "type": "RestElement", + "range": [ + 48, + 69 + ], + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 69 + } + }, "argument": { + "type": "Identifier", + "range": [ + 51, + 55 + ], "loc": { - "end": { - "line": 1, - "column": 55 - }, "start": { "line": 1, "column": 51 + }, + "end": { + "line": 1, + "column": 55 } }, "name": "args", - "range": [ - 51, - 55 - ], - "type": "Identifier", "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "line": 1, - "column": 69 - }, "start": { "line": 1, "column": 56 + }, + "end": { + "line": 1, + "column": 69 } }, "range": [ 56, 69 ], - "type": "TypeAnnotation", "typeAnnotation": { + "type": "TSTypeReference", + "range": [ + 56, + 69 + ], "loc": { - "end": { - "line": 1, - "column": 69 - }, "start": { "line": 1, "column": 56 + }, + "end": { + "line": 1, + "column": 69 } }, - "range": [ - 56, - 69 - ], - "type": "TSTypeReference", "typeName": { + "type": "Identifier", + "range": [ + 56, + 61 + ], "loc": { - "end": { - "line": 1, - "column": 61 - }, "start": { "line": 1, "column": 56 + }, + "end": { + "line": 1, + "column": 61 } }, - "name": "Array", - "range": [ - 56, - 61 - ], - "type": "Identifier" + "name": "Array" }, "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 61, + 69 + ], "loc": { - "end": { - "column": 69, - "line": 1 - }, "start": { - "column": 61, - "line": 1 + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 69 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 68, - "line": 1 - }, - "start": { - "column": 62, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 62, + 68 + ], + "loc": { + "start": { + "line": 1, + "column": 62 }, + "end": { + "line": 1, + "column": 68 + } + }, + "id": { + "type": "TSStringKeyword", "range": [ 62, 68 ], - "type": "TSStringKeyword" - }, - - "loc": { - "end": { - "column": 68, - "line": 1 - }, - "start": { - "column": 62, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 62 + }, + "end": { + "line": 1, + "column": 68 + } } }, - "range": [ - 62, - 68 - ], - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "range": [ - 61, - 69 - ], - "type": "TypeParameterInstantiation" + ] } } } - }, - "loc": { - "end": { - "line": 1, - "column": 69 - }, - "start": { - "line": 1, - "column": 48 - } - }, - "range": [ - 48, - 69 - ], - "type": "RestElement" + } } ], - "returnType": { - "type": "TypeAnnotation", + "body": { + "type": "BlockStatement", "range": [ - 71, - 77 + 78, + 96 ], "loc": { - "end": { + "start": { "line": 1, - "column": 77 + "column": 78 }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ReturnStatement", + "range": [ + 82, + 94 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "argument": { + "type": "Identifier", + "range": [ + 89, + 93 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "name": "name" + } + } + ] + }, + "returnType": { + "type": "TypeAnnotation", + "loc": { "start": { "line": 1, "column": 71 + }, + "end": { + "line": 1, + "column": 77 } }, + "range": [ + 71, + 77 + ], "typeAnnotation": { "type": "TSStringKeyword", "range": [ @@ -413,13 +412,13 @@ module.exports = { 77 ], "loc": { - "end": { - "line": 1, - "column": 77 - }, "start": { "line": 1, "column": 71 + }, + "end": { + "line": 1, + "column": 77 } } } @@ -430,507 +429,507 @@ module.exports = { "tokens": [ { "type": "Keyword", + "value": "function", "range": [ 0, 8 ], "loc": { - "end": { - "line": 1, - "column": 8 - }, "start": { "line": 1, "column": 0 + }, + "end": { + "line": 1, + "column": 8 } - }, - "value": "function" + } }, { "type": "Identifier", + "value": "message", "range": [ 9, 16 ], "loc": { - "end": { - "line": 1, - "column": 16 - }, "start": { "line": 1, "column": 9 + }, + "end": { + "line": 1, + "column": 16 } - }, - "value": "message" + } }, { "type": "Punctuator", + "value": "(", "range": [ 16, 17 ], "loc": { - "end": { - "line": 1, - "column": 17 - }, "start": { "line": 1, "column": 16 + }, + "end": { + "line": 1, + "column": 17 } - }, - "value": "(" + } }, { "type": "Identifier", + "value": "name", "range": [ 17, 21 ], "loc": { - "end": { - "line": 1, - "column": 21 - }, "start": { "line": 1, "column": 17 + }, + "end": { + "line": 1, + "column": 21 } - }, - "value": "name" + } }, { "type": "Punctuator", + "value": ":", "range": [ 21, 22 ], "loc": { - "end": { - "line": 1, - "column": 22 - }, "start": { "line": 1, "column": 21 + }, + "end": { + "line": 1, + "column": 22 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 22, 28 ], "loc": { - "end": { - "line": 1, - "column": 28 - }, "start": { "line": 1, "column": 22 + }, + "end": { + "line": 1, + "column": 28 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ",", "range": [ 28, 29 ], "loc": { - "end": { - "line": 1, - "column": 29 - }, "start": { "line": 1, "column": 28 + }, + "end": { + "line": 1, + "column": 29 } - }, - "value": "," + } }, { "type": "Identifier", + "value": "age", "range": [ 30, 33 ], "loc": { - "end": { - "line": 1, - "column": 33 - }, "start": { "line": 1, "column": 30 + }, + "end": { + "line": 1, + "column": 33 } - }, - "value": "age" + } }, { "type": "Punctuator", + "value": ":", "range": [ 33, 34 ], "loc": { - "end": { - "line": 1, - "column": 34 - }, "start": { "line": 1, "column": 33 + }, + "end": { + "line": 1, + "column": 34 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "number", "range": [ 34, 40 ], "loc": { - "end": { - "line": 1, - "column": 40 - }, "start": { "line": 1, "column": 34 + }, + "end": { + "line": 1, + "column": 40 } - }, - "value": "number" + } }, { "type": "Punctuator", + "value": "=", "range": [ 41, 42 ], "loc": { - "end": { - "line": 1, - "column": 42 - }, "start": { "line": 1, "column": 41 + }, + "end": { + "line": 1, + "column": 42 } - }, - "value": "=" + } }, { "type": "Numeric", + "value": "100", "range": [ 43, 46 ], "loc": { - "end": { - "line": 1, - "column": 46 - }, "start": { "line": 1, "column": 43 + }, + "end": { + "line": 1, + "column": 46 } - }, - "value": "100" + } }, { "type": "Punctuator", + "value": ",", "range": [ 46, 47 ], "loc": { - "end": { - "line": 1, - "column": 47 - }, "start": { "line": 1, "column": 46 + }, + "end": { + "line": 1, + "column": 47 } - }, - "value": "," + } }, { "type": "Punctuator", + "value": "...", "range": [ 48, 51 ], "loc": { - "end": { - "line": 1, - "column": 51 - }, "start": { "line": 1, "column": 48 + }, + "end": { + "line": 1, + "column": 51 } - }, - "value": "..." + } }, { "type": "Identifier", + "value": "args", "range": [ 51, 55 ], "loc": { - "end": { - "line": 1, - "column": 55 - }, "start": { "line": 1, "column": 51 + }, + "end": { + "line": 1, + "column": 55 } - }, - "value": "args" + } }, { "type": "Punctuator", + "value": ":", "range": [ 55, 56 ], "loc": { - "end": { - "line": 1, - "column": 56 - }, "start": { "line": 1, "column": 55 + }, + "end": { + "line": 1, + "column": 56 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "Array", "range": [ 56, 61 ], "loc": { - "end": { - "line": 1, - "column": 61 - }, "start": { "line": 1, "column": 56 + }, + "end": { + "line": 1, + "column": 61 } - }, - "value": "Array" + } }, { "type": "Punctuator", + "value": "<", "range": [ 61, 62 ], "loc": { - "end": { - "line": 1, - "column": 62 - }, "start": { "line": 1, "column": 61 + }, + "end": { + "line": 1, + "column": 62 } - }, - "value": "<" + } }, { "type": "Identifier", + "value": "string", "range": [ 62, 68 ], "loc": { - "end": { - "line": 1, - "column": 68 - }, "start": { "line": 1, "column": 62 + }, + "end": { + "line": 1, + "column": 68 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": ">", "range": [ 68, 69 ], "loc": { - "end": { - "line": 1, - "column": 69 - }, "start": { "line": 1, "column": 68 + }, + "end": { + "line": 1, + "column": 69 } - }, - "value": ">" + } }, { "type": "Punctuator", + "value": ")", "range": [ 69, 70 ], "loc": { - "end": { - "line": 1, - "column": 70 - }, "start": { "line": 1, "column": 69 + }, + "end": { + "line": 1, + "column": 70 } - }, - "value": ")" + } }, { "type": "Punctuator", + "value": ":", "range": [ 70, 71 ], "loc": { - "end": { - "line": 1, - "column": 71 - }, "start": { "line": 1, "column": 70 + }, + "end": { + "line": 1, + "column": 71 } - }, - "value": ":" + } }, { "type": "Identifier", + "value": "string", "range": [ 71, 77 ], "loc": { - "end": { - "line": 1, - "column": 77 - }, "start": { "line": 1, "column": 71 + }, + "end": { + "line": 1, + "column": 77 } - }, - "value": "string" + } }, { "type": "Punctuator", + "value": "{", "range": [ 78, 79 ], "loc": { - "end": { - "line": 1, - "column": 79 - }, "start": { "line": 1, "column": 78 + }, + "end": { + "line": 1, + "column": 79 } - }, - "value": "{" + } }, { "type": "Keyword", + "value": "return", "range": [ 82, 88 ], "loc": { - "end": { - "line": 2, - "column": 8 - }, "start": { "line": 2, "column": 2 + }, + "end": { + "line": 2, + "column": 8 } - }, - "value": "return" + } }, { "type": "Identifier", + "value": "name", "range": [ 89, 93 ], "loc": { - "end": { - "line": 2, - "column": 13 - }, "start": { "line": 2, "column": 9 + }, + "end": { + "line": 2, + "column": 13 } - }, - "value": "name" + } }, { "type": "Punctuator", + "value": ";", "range": [ 93, 94 ], "loc": { - "end": { - "line": 2, - "column": 14 - }, "start": { "line": 2, "column": 13 + }, + "end": { + "line": 2, + "column": 14 } - }, - "value": ";" + } }, { "type": "Punctuator", + "value": "}", "range": [ 95, 96 ], "loc": { - "end": { - "line": 3, - "column": 1 - }, "start": { "line": 3, "column": 0 + }, + "end": { + "line": 3, + "column": 1 } - }, - "value": "}" + } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/interface-with-all-property-types.result.js b/tests/fixtures/typescript/basics/interface-with-all-property-types.result.js index bae2be7..72601f0 100644 --- a/tests/fixtures/typescript/basics/interface-with-all-property-types.result.js +++ b/tests/fixtures/typescript/basics/interface-with-all-property-types.result.js @@ -17,7 +17,6 @@ module.exports = { "body": [ { "type": "TSInterfaceDeclaration", - "abstract": false, "range": [ 0, 295 @@ -32,6 +31,7 @@ module.exports = { "column": 1 } }, + "abstract": false, "body": { "type": "TSInterfaceBody", "body": [ @@ -479,7 +479,6 @@ module.exports = { } }, "name": "fff", - "optional": true, "typeAnnotation": { "type": "TypeAnnotation", "loc": { @@ -513,7 +512,8 @@ module.exports = { } } } - } + }, + "optional": true }, "typeAnnotation": { "type": "TypeAnnotation", @@ -1018,6 +1018,10 @@ module.exports = { } } }, + "accessibility": null, + "readonly": false, + "static": false, + "export": false, "typeParameters": { "type": "TypeParameterDeclaration", "range": [ @@ -1055,11 +1059,7 @@ module.exports = { "constraint": null } ] - }, - "accessibility": null, - "readonly": false, - "static": false, - "export": false + } }, { "type": "TSConstructSignature", @@ -3335,4 +3335,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.result.js b/tests/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.result.js index 8e7e7b6..4fb6325 100644 --- a/tests/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.result.js +++ b/tests/fixtures/typescript/basics/interface-with-construct-signature-with-parameter-accessibility.result.js @@ -69,9 +69,9 @@ module.exports = { } }, "accessibility": "public", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "Identifier", "range": [ @@ -108,9 +108,9 @@ module.exports = { } }, "accessibility": "private", + "readonly": false, "static": false, "export": false, - "readonly": false, "parameter": { "type": "Identifier", "range": [ @@ -407,4 +407,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/interface-with-jsdoc.result.js b/tests/fixtures/typescript/basics/interface-with-jsdoc.result.js index a45c01b..140dbae 100644 --- a/tests/fixtures/typescript/basics/interface-with-jsdoc.result.js +++ b/tests/fixtures/typescript/basics/interface-with-jsdoc.result.js @@ -677,4 +677,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/interface-with-optional-properties.result.js b/tests/fixtures/typescript/basics/interface-with-optional-properties.result.js index 27d058c..5af78ee 100644 --- a/tests/fixtures/typescript/basics/interface-with-optional-properties.result.js +++ b/tests/fixtures/typescript/basics/interface-with-optional-properties.result.js @@ -226,7 +226,6 @@ module.exports = { } }, "name": "bar", - "optional": true, "typeAnnotation": { "type": "TypeAnnotation", "loc": { @@ -260,7 +259,8 @@ module.exports = { } } } - } + }, + "optional": true }, { "type": "Identifier", @@ -796,4 +796,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/interface-without-type-annotation.result.js b/tests/fixtures/typescript/basics/interface-without-type-annotation.result.js index 560bbb2..e307ccc 100644 --- a/tests/fixtures/typescript/basics/interface-without-type-annotation.result.js +++ b/tests/fixtures/typescript/basics/interface-without-type-annotation.result.js @@ -226,4 +226,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 index e8c62c8..8d9cd85 100644 --- a/tests/fixtures/typescript/basics/nested-type-arguments.result.js +++ b/tests/fixtures/typescript/basics/nested-type-arguments.result.js @@ -1,526 +1,526 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 44 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, "body": [ { + "type": "VariableDeclaration", + "range": [ + 0, + 44 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, "declarations": [ { + "type": "VariableDeclarator", + "range": [ + 4, + 44 + ], + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 44 + } + }, "id": { + "type": "Identifier", + "range": [ + 4, + 15 + ], "loc": { - "end": { - "column": 15, - "line": 1 - }, "start": { - "column": 4, - "line": 1 + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 15 } }, "name": "nestedArray", - "range": [ - 4, - 15 - ], - "type": "Identifier", "typeAnnotation": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 44, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 44 } }, "range": [ 17, 44 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 44, - "line": 1 - }, - "start": { - "column": 17, - "line": 1 - } - }, + "type": "TSTypeReference", "range": [ 17, 44 ], - "type": "TSTypeReference", - "typeParameters": { + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "typeName": { + "type": "Identifier", + "range": [ + 17, + 22 + ], "loc": { - "end": { - "column": 44, - "line": 1 + "start": { + "line": 1, + "column": 17 }, + "end": { + "line": 1, + "column": 22 + } + }, + "name": "Array" + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 22, + 44 + ], + "loc": { "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 44 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 28, - "line": 1 - }, - "start": { - "column": 23, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 23, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 23 }, - "name": "Array", + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", "range": [ 23, 28 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 43, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } }, - "start": { - "column": 23, - "line": 1 - } + "name": "Array" }, - "range": [ - 23, - 43 - ], - "type": "GenericTypeAnnotation", "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 28, + 43 + ], "loc": { - "end": { - "column": 43, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 43 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 34, - "line": 1 - }, - "start": { - "column": 29, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 29, + 42 + ], + "loc": { + "start": { + "line": 1, + "column": 29 }, - "name": "Array", + "end": { + "line": 1, + "column": 42 + } + }, + "id": { + "type": "Identifier", "range": [ 29, 34 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 42, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + } }, - "start": { - "column": 29, - "line": 1 - } + "name": "Array" }, - "range": [ - 29, - 42 - ], - "type": "GenericTypeAnnotation", "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 34, + 42 + ], "loc": { - "end": { - "column": 42, - "line": 1 - }, "start": { - "column": 34, - "line": 1 + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 42 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 41, - "line": 1 - }, - "start": { - "column": 35, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 35, + 41 + ], + "loc": { + "start": { + "line": 1, + "column": 35 }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "TSStringKeyword", "range": [ 35, 41 ], - "type": "TSStringKeyword" - }, - "loc": { - "end": { - "column": 41, - "line": 1 - }, - "start": { - "column": 35, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 + } } }, - "range": [ - 35, - 41 - ], - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "range": [ - 34, - 42 - ], - "type": "TypeParameterInstantiation" + ] } } - ], - "range": [ - 28, - 43 - ], - "type": "TypeParameterInstantiation" + ] } } - ], - "range": [ - 22, - 44 - ], - "type": "TypeParameterInstantiation" - }, - "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" + "init": null } ], - "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 + "kind": "var" } - }, - "range": [ - 0, - 44 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 3, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "var", "range": [ 0, 3 ], - "type": "Keyword", - "value": "var" - }, - { "loc": { - "end": { - "column": 15, - "line": 1 - }, "start": { - "column": 4, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 } - }, + } + }, + { + "type": "Identifier", + "value": "nestedArray", "range": [ 4, 15 ], - "type": "Identifier", - "value": "nestedArray" - }, - { "loc": { - "end": { - "column": 16, - "line": 1 - }, "start": { - "column": 15, - "line": 1 + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": ":", "range": [ 15, 16 ], - "type": "Punctuator", - "value": ":" - }, - { "loc": { - "end": { - "column": 22, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 } - }, + } + }, + { + "type": "Identifier", + "value": "Array", "range": [ 17, 22 ], - "type": "Identifier", - "value": "Array" - }, - { "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 22, 23 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 28, - "line": 1 - }, "start": { - "column": 23, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 } - }, + } + }, + { + "type": "Identifier", + "value": "Array", "range": [ 23, 28 ], - "type": "Identifier", - "value": "Array" - }, - { "loc": { - "end": { - "column": 29, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 28, 29 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 34, - "line": 1 - }, "start": { - "column": 29, - "line": 1 + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 } - }, + } + }, + { + "type": "Identifier", + "value": "Array", "range": [ 29, 34 ], - "type": "Identifier", - "value": "Array" - }, - { "loc": { - "end": { - "column": 35, - "line": 1 - }, "start": { - "column": 34, - "line": 1 + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 34, 35 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 41, - "line": 1 - }, "start": { - "column": 35, - "line": 1 + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 } - }, + } + }, + { + "type": "Identifier", + "value": "string", "range": [ 35, 41 ], - "type": "Identifier", - "value": "string" - }, - { "loc": { - "end": { - "column": 42, - "line": 1 - }, "start": { - "column": 41, - "line": 1 + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 41, 42 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 43, - "line": 1 - }, "start": { - "column": 42, - "line": 1 + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 42, 43 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 44, - "line": 1 - }, "start": { - "column": 43, - "line": 1 + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 43, 44 ], - "type": "Punctuator", - "value": ">" + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/non-null-assertion-operator.result.js b/tests/fixtures/typescript/basics/non-null-assertion-operator.result.js index 3cab39a..1655edd 100644 --- a/tests/fixtures/typescript/basics/non-null-assertion-operator.result.js +++ b/tests/fixtures/typescript/basics/non-null-assertion-operator.result.js @@ -70,7 +70,6 @@ module.exports = { } }, "name": "e", - "optional": true, "typeAnnotation": { "type": "TypeAnnotation", "loc": { @@ -122,7 +121,8 @@ module.exports = { "name": "Entity" } } - } + }, + "optional": true } ], "body": { @@ -761,4 +761,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.result.js b/tests/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.result.js index f2a8f46..062b16c 100644 --- a/tests/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.result.js +++ b/tests/fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.result.js @@ -1,76 +1,108 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, "body": [ { + "type": "VariableDeclaration", + "range": [ + 0, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "kind": "type", "declarations": [ { + "type": "VariableDeclarator", "id": { - "loc": { - "end": { - "column": 11, - "line": 1 - }, - "start": { - "column": 5, - "line": 1 - } - }, - "name": "Result", + "type": "Identifier", "range": [ 5, 11 ], - "type": "Identifier" - }, - "init": { "loc": { - "end": { - "column": 48, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 } }, + "name": "Result" + }, + "init": { + "type": "TSUnionType", "range": [ 28, 48 ], - "type": "TSUnionType", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 48 + } + }, "types": [ { - "loc": { - "end": { - "column": 38, - "line": 1 - }, - "start": { - "column": 28, - "line": 1 - } - }, + "type": "TSTypeReference", "range": [ 28, 38 ], - "type": "TSTypeReference", - "typeName": { - "loc": { - "end": { - "column": 35, - "line": 1 - }, - "start": { - "column": 28, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 28 }, - "name": "Success", + "end": { + "line": 1, + "column": 38 + } + }, + "typeName": { + "type": "Identifier", "range": [ 28, 35 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "name": "Success" }, "typeParameters": { "type": "TypeParameterInstantiation", @@ -79,485 +111,453 @@ module.exports = { 38 ], "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 35, - "line": 1 + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 38 } }, "params": [ { - "loc": { - "end": { - "column": 37, - "line": 1 - }, - "start": { - "column": 36, - "line": 1 - } - }, + "type": "GenericTypeAnnotation", "range": [ 36, 37 ], - "id": { - "loc": { - "end": { - "column": 37, - "line": 1 - }, - "start": { - "column": 36, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 36 }, - "name": "T", + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", "range": [ 36, 37 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "name": "T" }, - "type": "GenericTypeAnnotation", "typeParameters": null } ] } }, { - "loc": { - "end": { - "column": 48, - "line": 1 - }, - "start": { - "column": 41, - "line": 1 - } - }, + "type": "TSTypeReference", "range": [ 41, 48 ], - "type": "TSTypeReference", - "typeName": { - "loc": { - "end": { - "column": 48, - "line": 1 - }, - "start": { - "column": 41, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 41 }, - "name": "Failure", + "end": { + "line": 1, + "column": 48 + } + }, + "typeName": { + "type": "Identifier", "range": [ 41, 48 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "name": "Failure" } } ] }, - "loc": { - "end": { - "column": 48, - "line": 1 - }, - "start": { - "column": 5, - "line": 1 - } - }, "range": [ 5, 48 ], - "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 48 + } + }, "typeParameters": { + "type": "TypeParameterDeclaration", + "range": [ + 11, + 25 + ], "loc": { - "end": { - "column": 25, - "line": 1 - }, "start": { - "column": 11, - "line": 1 + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 25 } }, "params": [ { + "type": "TypeParameter", + "range": [ + 12, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "name": "T", "constraint": { + "type": "TypeAnnotation", "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 } }, "range": [ 22, 24 ], - "type": "TypeAnnotation", "typeAnnotation": { - "loc": { - "end": { - "column": 24, - "line": 1 - }, - "start": { - "column": 22, - "line": 1 - } - }, - "members": [], + "type": "TSTypeLiteral", "range": [ 22, 24 ], - "type": "TSTypeLiteral" - } - }, - "loc": { - "end": { - "column": 24, - "line": 1 - }, - "start": { - "column": 12, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "members": [] } - }, - "name": "T", - "range": [ - 12, - 24 - ], - "type": "TypeParameter" + } } - ], - "range": [ - 11, - 25 - ], - "type": "TypeParameterDeclaration" + ] } } - ], - "kind": "type", - "loc": { - "end": { - "column": 48, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 48 - ], - "type": "VariableDeclaration" - } - ], - "loc": { - "end": { - "column": 48, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 + ] } - }, - "range": [ - 0, - 48 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 4, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Identifier", + "value": "type", "range": [ 0, 4 ], - "type": "Identifier", - "value": "type" - }, - { "loc": { - "end": { - "column": 11, - "line": 1 - }, "start": { - "column": 5, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 } - }, + } + }, + { + "type": "Identifier", + "value": "Result", "range": [ 5, 11 ], - "type": "Identifier", - "value": "Result" - }, - { "loc": { - "end": { - "column": 12, - "line": 1 - }, "start": { - "column": 11, - "line": 1 + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 11, 12 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 13, - "line": 1 - }, "start": { - "column": 12, - "line": 1 + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 } - }, + } + }, + { + "type": "Identifier", + "value": "T", "range": [ 12, 13 ], - "type": "Identifier", - "value": "T" - }, - { "loc": { - "end": { - "column": 21, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 } - }, + } + }, + { + "type": "Keyword", + "value": "extends", "range": [ 14, 21 ], - "type": "Keyword", - "value": "extends" - }, - { "loc": { - "end": { - "column": 23, - "line": 1 - }, "start": { - "column": 22, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 21 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 22, 23 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 23, - "line": 1 + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 23, 24 ], - "type": "Punctuator", - "value": "}" - }, - { "loc": { - "end": { - "column": 25, - "line": 1 - }, "start": { - "column": 24, - "line": 1 + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 24, 25 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 27, - "line": 1 - }, "start": { - "column": 26, - "line": 1 + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 } - }, + } + }, + { + "type": "Punctuator", + "value": "=", "range": [ 26, 27 ], - "type": "Punctuator", - "value": "=" - }, - { "loc": { - "end": { - "column": 35, - "line": 1 - }, "start": { - "column": 28, - "line": 1 + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 } - }, + } + }, + { + "type": "Identifier", + "value": "Success", "range": [ 28, 35 ], - "type": "Identifier", - "value": "Success" - }, - { "loc": { - "end": { - "column": 36, - "line": 1 - }, "start": { - "column": 35, - "line": 1 + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 35 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 35, 36 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 37, - "line": 1 - }, "start": { - "column": 36, - "line": 1 + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 } - }, + } + }, + { + "type": "Identifier", + "value": "T", "range": [ 36, 37 ], - "type": "Identifier", - "value": "T" - }, - { "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 37, - "line": 1 + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 37, 38 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 40, - "line": 1 - }, "start": { - "column": 39, - "line": 1 + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 } - }, + } + }, + { + "type": "Punctuator", + "value": "|", "range": [ 39, 40 ], - "type": "Punctuator", - "value": "|" - }, - { "loc": { - "end": { - "column": 48, - "line": 1 - }, "start": { - "column": 41, - "line": 1 + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 } - }, + } + }, + { + "type": "Identifier", + "value": "Failure", "range": [ 41, 48 ], - "type": "Identifier", - "value": "Failure" + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 48 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/type-alias-declaration.result.js b/tests/fixtures/typescript/basics/type-alias-declaration.result.js index c6c963f..5389122 100644 --- a/tests/fixtures/typescript/basics/type-alias-declaration.result.js +++ b/tests/fixtures/typescript/basics/type-alias-declaration.result.js @@ -105,59 +105,59 @@ module.exports = { "name": "Success" }, "typeParameters": { - "loc": { - "end": { - "column": 27, - "line": 1 - }, - "start": { - "column": 24, - "line": 1 - } - }, + "type": "TypeParameterInstantiation", "range": [ 24, 27 ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, "params": [ { - "loc": { - "end": { - "column": 26, - "line": 1 - }, - "start": { - "column": 25, - "line": 1 - } - }, + "type": "GenericTypeAnnotation", "range": [ 25, 26 ], - "id": { - "loc": { - "end": { - "column": 26, - "line": 1 - }, - "start": { - "column": 25, - "line": 1 - } + "loc": { + "start": { + "line": 1, + "column": 25 }, - "name": "T", + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", "range": [ 25, 26 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": "T" }, - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "type": "TypeParameterInstantiation" + ] } }, { @@ -472,4 +472,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/type-alias-object-without-annotation.result.js b/tests/fixtures/typescript/basics/type-alias-object-without-annotation.result.js index 46e51d8..986ef45 100644 --- a/tests/fixtures/typescript/basics/type-alias-object-without-annotation.result.js +++ b/tests/fixtures/typescript/basics/type-alias-object-without-annotation.result.js @@ -410,4 +410,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/type-guard.result.js b/tests/fixtures/typescript/basics/type-guard.result.js index 38131df..9f70665 100644 --- a/tests/fixtures/typescript/basics/type-guard.result.js +++ b/tests/fixtures/typescript/basics/type-guard.result.js @@ -1,627 +1,634 @@ module.exports = { - "body": [{ - "async": false, - "body": { - "body": [{ - "argument": { - "left": { - "argument": { - "loc": { - "end": { - "column": 19, - "line": 2 - }, - "start": { - "column": 18, - "line": 2 - } - }, - "name": "x", - "range": [ - 59, - 60 - ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 19, - "line": 2 - }, - "start": { - "column": 11, - "line": 2 - } - }, - "operator": "typeof", - "prefix": true, - "range": [ - 52, - 60 - ], - "type": "UnaryExpression" - }, - "loc": { - "end": { - "column": 32, - "line": 2 - }, - "start": { - "column": 11, - "line": 2 - } - }, - "operator": "===", - "range": [ - 52, - 73 - ], - "right": { - "loc": { - "end": { - "column": 32, - "line": 2 - }, - "start": { - "column": 24, - "line": 2 - } - }, - "range": [ - 65, - 73 - ], - "raw": "'string'", - "type": "Literal", - "value": "string" - }, - "type": "BinaryExpression" - }, - "loc": { - "end": { - "column": 32, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } - }, - "range": [ - 45, - 73 - ], - "type": "ReturnStatement" - }], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 39, - "line": 1 - } - }, + "type": "Program", + "range": [ + 0, + 75 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", "range": [ - 39, + 0, 75 ], - "type": "BlockStatement" - }, - "expression": false, - "generator": false, - "id": { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 9, - "line": 1 - } - }, - "name": "isString", - "range": [ - 9, - 17 - ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "params": [{ - "loc": { - "end": { - "column": 19, - "line": 1 + "line": 1, + "column": 0 }, - "start": { - "column": 18, - "line": 1 + "end": { + "line": 3, + "column": 1 } }, - "name": "x", - "range": [ - 18, - 19 - ], - "type": "Identifier", - "typeAnnotation": { + "id": { + "type": "Identifier", + "range": [ + 9, + 17 + ], "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 } }, - "range": [ - 21, - 24 - ], - "type": "TypeAnnotation", - "typeAnnotation": { + "name": "isString" + }, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "Identifier", + "range": [ + 18, + 19 + ], "loc": { - "end": { - "column": 24, - "line": 1 - }, "start": { - "column": 21, - "line": 1 + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 } }, - "range": [ - 21, - 24 - ], - "type": "TSAnyKeyword" - } - } - }], - "range": [ - 0, - 75 - ], - "returnType": { - "loc": { - "end": { - "column": 38, - "line": 1 - }, - "start": { - "column": 27, - "line": 1 + "name": "x", + "typeAnnotation": { + "type": "TypeAnnotation", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 21, + 24 + ], + "typeAnnotation": { + "type": "TSAnyKeyword", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } } - }, - "range": [ - 27, - 38 ], - "type": "TypeAnnotation", - "typeAnnotation": { + "body": { + "type": "BlockStatement", + "range": [ + 39, + 75 + ], "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 27, - "line": 1 + "line": 1, + "column": 39 + }, + "end": { + "line": 3, + "column": 1 } }, - "parameterName": { - "loc": { - "end": { - "column": 28, - "line": 1 + "body": [ + { + "type": "ReturnStatement", + "range": [ + 45, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 32 + } }, - "start": { - "column": 27, - "line": 1 + "argument": { + "type": "BinaryExpression", + "range": [ + 52, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "operator": "===", + "left": { + "type": "UnaryExpression", + "range": [ + 52, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "operator": "typeof", + "prefix": true, + "argument": { + "type": "Identifier", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "x" + } + }, + "right": { + "type": "Literal", + "range": [ + 65, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "value": "string", + "raw": "'string'" + } } + } + ] + }, + "returnType": { + "type": "TypeAnnotation", + "loc": { + "start": { + "line": 1, + "column": 27 }, - "name": "x", - "range": [ - 27, - 28 - ], - "type": "Identifier" + "end": { + "line": 1, + "column": 38 + } }, "range": [ 27, 38 ], - "type": "TSTypePredicate", "typeAnnotation": { + "type": "TSTypePredicate", + "range": [ + 27, + 38 + ], "loc": { - "end": { - "column": 38, - "line": 1 - }, "start": { - "column": 32, - "line": 1 + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 38 } }, - "range": [ - 32, - 38 - ], - "type": "TypeAnnotation", - "typeAnnotation": { + "parameterName": { + "type": "Identifier", + "range": [ + 27, + 28 + ], "loc": { - "end": { - "column": 38, - "line": 1 + "start": { + "line": 1, + "column": 27 }, + "end": { + "line": 1, + "column": 28 + } + }, + "name": "x" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "loc": { "start": { - "column": 32, - "line": 1 + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 } }, "range": [ 32, 38 ], - "type": "TSStringKeyword" + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + } + } } } } - }, - "type": "FunctionDeclaration" - }], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 } - }, - "range": [ - 0, - 75 ], "sourceType": "script", - "tokens": [{ - "loc": { - "end": { - "column": 8, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 + "tokens": [ + { + "type": "Keyword", + "value": "function", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } } }, - "range": [ - 0, - 8 - ], - "type": "Keyword", - "value": "function" - }, - { - "loc": { - "end": { - "column": 17, - "line": 1 - }, - "start": { - "column": 9, - "line": 1 + { + "type": "Identifier", + "value": "isString", + "range": [ + 9, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } } }, - "range": [ - 9, - 17 - ], - "type": "Identifier", - "value": "isString" - }, - { - "loc": { - "end": { - "column": 18, - "line": 1 - }, - "start": { - "column": 17, - "line": 1 + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } } }, - "range": [ - 17, - 18 - ], - "type": "Punctuator", - "value": "(" - }, - { - "loc": { - "end": { - "column": 19, - "line": 1 - }, - "start": { - "column": 18, - "line": 1 + { + "type": "Identifier", + "value": "x", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } } }, - "range": [ - 18, - 19 - ], - "type": "Identifier", - "value": "x" - }, - { - "loc": { - "end": { - "column": 20, - "line": 1 - }, - "start": { - "column": 19, - "line": 1 + { + "type": "Punctuator", + "value": ":", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } } }, - "range": [ - 19, - 20 - ], - "type": "Punctuator", - "value": ":" - }, - { - "loc": { - "end": { - "column": 24, - "line": 1 - }, - "start": { - "column": 21, - "line": 1 + { + "type": "Identifier", + "value": "any", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } } }, - "range": [ - 21, - 24 - ], - "type": "Identifier", - "value": "any" - }, - { - "loc": { - "end": { - "column": 25, - "line": 1 - }, - "start": { - "column": 24, - "line": 1 + { + "type": "Punctuator", + "value": ")", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } } }, - "range": [ - 24, - 25 - ], - "type": "Punctuator", - "value": ")" - }, - { - "loc": { - "end": { - "column": 26, - "line": 1 - }, - "start": { - "column": 25, - "line": 1 + { + "type": "Punctuator", + "value": ":", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } } }, - "range": [ - 25, - 26 - ], - "type": "Punctuator", - "value": ":" - }, - { - "loc": { - "end": { - "column": 28, - "line": 1 - }, - "start": { - "column": 27, - "line": 1 + { + "type": "Identifier", + "value": "x", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } } }, - "range": [ - 27, - 28 - ], - "type": "Identifier", - "value": "x" - }, - { - "loc": { - "end": { - "column": 31, - "line": 1 - }, - "start": { - "column": 29, - "line": 1 + { + "type": "Identifier", + "value": "is", + "range": [ + 29, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } } }, - "range": [ - 29, - 31 - ], - "type": "Identifier", - "value": "is" - }, - { - "loc": { - "end": { - "column": 38, - "line": 1 - }, - "start": { - "column": 32, - "line": 1 + { + "type": "Identifier", + "value": "string", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } } }, - "range": [ - 32, - 38 - ], - "type": "Identifier", - "value": "string" - }, - { - "loc": { - "end": { - "column": 40, - "line": 1 - }, - "start": { - "column": 39, - "line": 1 + { + "type": "Punctuator", + "value": "{", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } } }, - "range": [ - 39, - 40 - ], - "type": "Punctuator", - "value": "{" - }, - { - "loc": { - "end": { - "column": 10, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 + { + "type": "Keyword", + "value": "return", + "range": [ + 45, + 51 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } } }, - "range": [ - 45, - 51 - ], - "type": "Keyword", - "value": "return" - }, - { - "loc": { - "end": { - "column": 17, - "line": 2 - }, - "start": { - "column": 11, - "line": 2 + { + "type": "Keyword", + "value": "typeof", + "range": [ + 52, + 58 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } } }, - "range": [ - 52, - 58 - ], - "type": "Keyword", - "value": "typeof" - }, - { - "loc": { - "end": { - "column": 19, - "line": 2 - }, - "start": { - "column": 18, - "line": 2 + { + "type": "Identifier", + "value": "x", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } } }, - "range": [ - 59, - 60 - ], - "type": "Identifier", - "value": "x" - }, - { - "loc": { - "end": { - "column": 23, - "line": 2 - }, - "start": { - "column": 20, - "line": 2 + { + "type": "Punctuator", + "value": "===", + "range": [ + 61, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } } }, - "range": [ - 61, - 64 - ], - "type": "Punctuator", - "value": "===" - }, - { - "loc": { - "end": { - "column": 32, - "line": 2 - }, - "start": { - "column": 24, - "line": 2 + { + "type": "String", + "value": "'string'", + "range": [ + 65, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 32 + } } }, - "range": [ - 65, - 73 - ], - "type": "String", - "value": "'string'" - }, - { - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 3 + { + "type": "Punctuator", + "value": "}", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } } - }, - "range": [ - 74, - 75 - ], - "type": "Punctuator", - "value": "}" - } - ], - "type": "Program" -}; + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/typed-this.result.js b/tests/fixtures/typescript/basics/typed-this.result.js index d62448f..2b8a61b 100644 --- a/tests/fixtures/typescript/basics/typed-this.result.js +++ b/tests/fixtures/typescript/basics/typed-this.result.js @@ -777,4 +777,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/basics/var-with-dotted-type.result.js b/tests/fixtures/typescript/basics/var-with-dotted-type.result.js index c6e2d76..64bb25a 100644 --- a/tests/fixtures/typescript/basics/var-with-dotted-type.result.js +++ b/tests/fixtures/typescript/basics/var-with-dotted-type.result.js @@ -359,4 +359,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.result.js b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.result.js index 5ab2db2..e210bea 100644 --- a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.result.js +++ b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.result.js @@ -90,6 +90,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", @@ -220,6 +221,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", diff --git a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.result.js b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.result.js index ed82988..bb41d9b 100644 --- a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.result.js +++ b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.result.js @@ -90,6 +90,7 @@ module.exports = { "computed": false, "static": true, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", @@ -205,6 +206,7 @@ module.exports = { "computed": false, "static": true, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", diff --git a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.result.js b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.result.js index 0d6a772..f4f9f9f 100644 --- a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.result.js +++ b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-instance-member.result.js @@ -90,6 +90,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", @@ -167,6 +168,7 @@ module.exports = { "computed": false, "static": false, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", diff --git a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.result.js b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.result.js index c03092e..8b161b2 100644 --- a/tests/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.result.js +++ b/tests/fixtures/typescript/decorators/property-decorators/property-decorator-static-member.result.js @@ -90,6 +90,7 @@ module.exports = { "computed": false, "static": true, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", @@ -167,6 +168,7 @@ module.exports = { "computed": false, "static": true, "accessibility": null, + "readonly": false, "decorators": [ { "type": "Decorator", diff --git a/tests/fixtures/typescript/errorRecovery/class-empty-extends-implements.result.js b/tests/fixtures/typescript/errorRecovery/class-empty-extends-implements.result.js index dec45ce..1c3776e 100644 --- a/tests/fixtures/typescript/errorRecovery/class-empty-extends-implements.result.js +++ b/tests/fixtures/typescript/errorRecovery/class-empty-extends-implements.result.js @@ -201,4 +201,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/errorRecovery/class-empty-extends.result.js b/tests/fixtures/typescript/errorRecovery/class-empty-extends.result.js index 5f0f82e..cc88e51 100644 --- a/tests/fixtures/typescript/errorRecovery/class-empty-extends.result.js +++ b/tests/fixtures/typescript/errorRecovery/class-empty-extends.result.js @@ -165,4 +165,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/errorRecovery/class-extends-empty-implements.result.js b/tests/fixtures/typescript/errorRecovery/class-extends-empty-implements.result.js index 4c1f0ac..2b62549 100644 --- a/tests/fixtures/typescript/errorRecovery/class-extends-empty-implements.result.js +++ b/tests/fixtures/typescript/errorRecovery/class-extends-empty-implements.result.js @@ -218,4 +218,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/errorRecovery/interface-property-modifiers.result.js b/tests/fixtures/typescript/errorRecovery/interface-property-modifiers.result.js index 6d0710f..96d6235 100644 --- a/tests/fixtures/typescript/errorRecovery/interface-property-modifiers.result.js +++ b/tests/fixtures/typescript/errorRecovery/interface-property-modifiers.result.js @@ -4813,4 +4813,4 @@ module.exports = { } } ] -}; +}; \ 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 3dfc525..f8a47b5 100644 --- a/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js +++ b/tests/fixtures/typescript/expressions/call-expression-type-arguments.result.js @@ -16,474 +16,474 @@ module.exports = { }, "body": [ { + "type": "ExpressionStatement", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, "expression": { - "arguments": [], - "callee": { - "loc": { - "end": { - "column": 3, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } + "type": "CallExpression", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - "name": "foo", + "end": { + "line": 1, + "column": 8 + } + }, + "callee": { + "type": "Identifier", "range": [ 0, 3 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 8, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } }, - "start": { - "column": 0, - "line": 1 - } + "name": "foo" }, - "range": [ - 0, - 8 - ], - "type": "CallExpression", + "arguments": [], "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 3, + 6 + ], "loc": { - "end": { - "column": 6, - "line": 1 - }, "start": { - "column": 3, - "line": 1 + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 4, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 4, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 4 }, - "name": "A", + "end": { + "line": 1, + "column": 5 + } + }, + "id": { + "type": "Identifier", "range": [ 4, 5 ], - "type": "Identifier" - }, - "typeParameters": null, - "loc": { - "end": { - "column": 5, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } }, - "start": { - "column": 4, - "line": 1 - } + "name": "A" }, - "range": [ - 4, - 5 - ], - "type": "GenericTypeAnnotation" + "typeParameters": null } - ], - "range": [ - 3, - 6 - ], - "type": "TypeParameterInstantiation" + ] } - }, + } + }, + { + "type": "ExpressionStatement", + "range": [ + 10, + 24 + ], "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 0, - "line": 1 + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 } }, - "range": [ - 0, - 9 - ], - "type": "ExpressionStatement" - }, - { "expression": { - "arguments": [], - "callee": { - "loc": { - "end": { - "column": 3, - "line": 2 - }, - "start": { - "column": 0, - "line": 2 - } + "type": "CallExpression", + "range": [ + 10, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 0 }, - "name": "foo", + "end": { + "line": 2, + "column": 13 + } + }, + "callee": { + "type": "Identifier", "range": [ 10, 13 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 13, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } }, - "start": { - "column": 0, - "line": 2 - } + "name": "foo" }, - "range": [ - 10, - 23 - ], - "type": "CallExpression", + "arguments": [], "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 13, + 21 + ], "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 3, - "line": 2 + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 11 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 10, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 - } + "type": "GenericTypeAnnotation", + "range": [ + 14, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "TSNumberKeyword", "range": [ 14, 20 ], - "type": "TSNumberKeyword" - }, - "typeParameters": null, - "loc": { - "end": { - "column": 10, - "line": 2 - }, - "start": { - "column": 4, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } } }, - "range": [ - 14, - 20 - ], - "type": "GenericTypeAnnotation" + "typeParameters": null } - ], - "range": [ - 13, - 21 - ], - "type": "TypeParameterInstantiation" - } - }, - "loc": { - "end": { - "column": 14, - "line": 2 - }, - "start": { - "column": 0, - "line": 2 + ] } - }, - "range": [ - 10, - 24 - ], - "type": "ExpressionStatement" + } } ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 3, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Identifier", + "value": "foo", "range": [ 0, 3 ], - "type": "Identifier", - "value": "foo" - }, - { "loc": { - "end": { - "column": 4, - "line": 1 - }, "start": { - "column": 3, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 3, 4 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 5, - "line": 1 - }, "start": { - "column": 4, - "line": 1 + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 } - }, + } + }, + { + "type": "Identifier", + "value": "A", "range": [ 4, 5 ], - "type": "Identifier", - "value": "A" - }, - { "loc": { - "end": { - "column": 6, - "line": 1 - }, "start": { - "column": 5, - "line": 1 + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 5, 6 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 7, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 6, 7 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 8, - "line": 1 - }, "start": { - "column": 7, - "line": 1 + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 7, 8 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 8, - "line": 1 + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 8, 9 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 3, - "line": 2 - }, "start": { - "column": 0, - "line": 2 + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 } - }, + } + }, + { + "type": "Identifier", + "value": "foo", "range": [ 10, 13 ], - "type": "Identifier", - "value": "foo" - }, - { "loc": { - "end": { - "column": 4, - "line": 2 - }, "start": { - "column": 3, - "line": 2 + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 13, 14 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 10, - "line": 2 - }, "start": { - "column": 4, - "line": 2 + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 } - }, + } + }, + { + "type": "Identifier", + "value": "number", "range": [ 14, 20 ], - "type": "Identifier", - "value": "number" - }, - { "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 10, - "line": 2 + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 20, 21 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 12, - "line": 2 - }, "start": { - "column": 11, - "line": 2 + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 21, 22 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 13, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 22, 23 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 14, - "line": 2 - }, "start": { - "column": 13, - "line": 2 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 23, 24 ], - "type": "Punctuator", - "value": ";" + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + } } ] -}; +}; \ No newline at end of file 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 1d3d5bc..459bac2 100644 --- a/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js +++ b/tests/fixtures/typescript/expressions/new-expression-type-arguments.result.js @@ -1,366 +1,366 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, "body": [ { + "type": "VariableDeclaration", + "range": [ + 0, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, "declarations": [ { - "id": { - "loc": { - "end": { - "column": 7, - "line": 1 - }, - "start": { - "column": 6, - "line": 1 - } + "type": "VariableDeclarator", + "range": [ + 6, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 6 }, - "name": "a", + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", "range": [ 6, 7 ], - "type": "Identifier" + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "a" }, "init": { - "arguments": [], - "callee": { - "loc": { - "end": { - "column": 15, - "line": 1 - }, - "start": { - "column": 14, - "line": 1 - } + "type": "NewExpression", + "range": [ + 10, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 10 }, - "name": "A", + "end": { + "line": 1, + "column": 20 + } + }, + "callee": { + "type": "Identifier", "range": [ 14, 15 ], - "type": "Identifier" - }, - "loc": { - "end": { - "column": 20, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } }, - "start": { - "column": 10, - "line": 1 - } + "name": "A" }, - "range": [ - 10, - 20 - ], - "type": "NewExpression", + "arguments": [], "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 15, + 18 + ], "loc": { - "end": { - "column": 18, - "line": 1 - }, "start": { - "column": 15, - "line": 1 + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 17, - "line": 1 - }, - "start": { - "column": 16, - "line": 1 - } + "type": "GenericTypeAnnotation", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 16 }, - "name": "B", + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", "range": [ 16, 17 ], - "type": "Identifier" - }, - "typeParameters": null, - "loc": { - "end": { - "column": 17, - "line": 1 + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } }, - "start": { - "column": 16, - "line": 1 - } + "name": "B" }, - "range": [ - 16, - 17 - ], - "type": "GenericTypeAnnotation" + "typeParameters": null } - ], - "range": [ - 15, - 18 - ], - "type": "TypeParameterInstantiation" - } - }, - "loc": { - "end": { - "column": 20, - "line": 1 - }, - "start": { - "column": 6, - "line": 1 + ] } - }, - "range": [ - 6, - 20 - ], - "type": "VariableDeclarator" - } - ], - "kind": "const", - "loc": { - "end": { - "column": 21, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 + } } - }, - "range": [ - 0, - 21 ], - "type": "VariableDeclaration" - } - ], - "loc": { - "end": { - "column": 21, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 + "kind": "const" } - }, - "range": [ - 0, - 21 ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 5, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Keyword", + "value": "const", "range": [ 0, 5 ], - "type": "Keyword", - "value": "const" - }, - { "loc": { - "end": { - "column": 7, - "line": 1 - }, "start": { - "column": 6, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 } - }, + } + }, + { + "type": "Identifier", + "value": "a", "range": [ 6, 7 ], - "type": "Identifier", - "value": "a" - }, - { "loc": { - "end": { - "column": 9, - "line": 1 - }, "start": { - "column": 8, - "line": 1 + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 } - }, + } + }, + { + "type": "Punctuator", + "value": "=", "range": [ 8, 9 ], - "type": "Punctuator", - "value": "=" - }, - { "loc": { - "end": { - "column": 13, - "line": 1 - }, "start": { - "column": 10, - "line": 1 + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 } - }, + } + }, + { + "type": "Keyword", + "value": "new", "range": [ 10, 13 ], - "type": "Keyword", - "value": "new" - }, - { "loc": { - "end": { - "column": 15, - "line": 1 - }, "start": { - "column": 14, - "line": 1 + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 } - }, + } + }, + { + "type": "Identifier", + "value": "A", "range": [ 14, 15 ], - "type": "Identifier", - "value": "A" - }, - { "loc": { - "end": { - "column": 16, - "line": 1 - }, "start": { - "column": 15, - "line": 1 + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 } - }, + } + }, + { + "type": "Punctuator", + "value": "<", "range": [ 15, 16 ], - "type": "Punctuator", - "value": "<" - }, - { "loc": { - "end": { - "column": 17, - "line": 1 - }, "start": { - "column": 16, - "line": 1 + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 } - }, + } + }, + { + "type": "Identifier", + "value": "B", "range": [ 16, 17 ], - "type": "Identifier", - "value": "B" - }, - { "loc": { - "end": { - "column": 18, - "line": 1 - }, "start": { - "column": 17, - "line": 1 + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 } - }, + } + }, + { + "type": "Punctuator", + "value": ">", "range": [ 17, 18 ], - "type": "Punctuator", - "value": ">" - }, - { "loc": { - "end": { - "column": 19, - "line": 1 - }, "start": { - "column": 18, - "line": 1 + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 } - }, + } + }, + { + "type": "Punctuator", + "value": "(", "range": [ 18, 19 ], - "type": "Punctuator", - "value": "(" - }, - { "loc": { - "end": { - "column": 20, - "line": 1 - }, "start": { - "column": 19, - "line": 1 + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 } - }, + } + }, + { + "type": "Punctuator", + "value": ")", "range": [ 19, 20 ], - "type": "Punctuator", - "value": ")" - }, - { "loc": { - "end": { - "column": 21, - "line": 1 - }, "start": { - "column": 20, - "line": 1 + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 20, 21 ], - "type": "Punctuator", - "value": ";" + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + } } - ], - "type": "Program" -}; + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.result.js b/tests/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.result.js index 63172cd..da04e37 100644 --- a/tests/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.result.js +++ b/tests/fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.result.js @@ -1,349 +1,349 @@ module.exports = { + "type": "Program", + "range": [ + 0, + 56 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { + "type": "TSModuleDeclaration", + "range": [ + 0, + 56 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "modifiers": [ + { + "type": "TSDeclareKeyword", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ], + "name": { + "type": "Literal", + "range": [ + 15, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "value": "i-use-things", + "raw": "\"i-use-things\"" + }, "body": { + "type": "TSModuleBlock", + "range": [ + 30, + 56 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 3, + "column": 1 + } + }, "body": [ { - "loc": { - "end": { - "column": 22, - "line": 2 - }, - "start": { - "column": 2, - "line": 2 - } - }, + "type": "ImportDeclaration", "range": [ 34, 54 ], - "source": { - "loc": { - "end": { - "column": 21, - "line": 2 - }, - "start": { - "column": 17, - "line": 2 - } + "loc": { + "start": { + "line": 2, + "column": 2 }, + "end": { + "line": 2, + "column": 22 + } + }, + "source": { + "type": "Literal", "range": [ 49, 53 ], - "raw": "'fs'", - "type": "Literal", - "value": "fs" + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": "fs", + "raw": "'fs'" }, "specifiers": [ { + "type": "ImportDefaultSpecifier", + "range": [ + 41, + 43 + ], "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 9, - "line": 2 + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 } }, "local": { - "loc": { - "end": { - "column": 11, - "line": 2 - }, - "start": { - "column": 9, - "line": 2 - } - }, - "name": "fs", + "type": "Identifier", "range": [ 41, 43 ], - "type": "Identifier" - }, - "range": [ - 41, - 43 - ], - "type": "ImportDefaultSpecifier" + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "name": "fs" + } } - ], - "type": "ImportDeclaration" - } - ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 30, - "line": 1 - } - }, - "range": [ - 30, - 56 - ], - "type": "TSModuleBlock" - }, - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "modifiers": [ - { - "loc": { - "end": { - "column": 7, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 7 - ], - "type": "TSDeclareKeyword" - } - ], - "name": { - "loc": { - "end": { - "column": 29, - "line": 1 - }, - "start": { - "column": 15, - "line": 1 + ] } - }, - "range": [ - 15, - 29 - ], - "raw": "\"i-use-things\"", - "type": "Literal", - "value": "i-use-things" - }, - "range": [ - 0, - 56 - ], - "type": "TSModuleDeclaration" + ] + } } ], - "loc": { - "end": { - "column": 1, - "line": 3 - }, - "start": { - "column": 0, - "line": 1 - } - }, - "range": [ - 0, - 56 - ], "sourceType": "script", "tokens": [ { - "loc": { - "end": { - "column": 7, - "line": 1 - }, - "start": { - "column": 0, - "line": 1 - } - }, + "type": "Identifier", + "value": "declare", "range": [ 0, 7 ], - "type": "Identifier", - "value": "declare" - }, - { "loc": { - "end": { - "column": 14, - "line": 1 - }, "start": { - "column": 8, - "line": 1 + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 } - }, + } + }, + { + "type": "Identifier", + "value": "module", "range": [ 8, 14 ], - "type": "Identifier", - "value": "module" - }, - { "loc": { - "end": { - "column": 29, - "line": 1 - }, "start": { - "column": 15, - "line": 1 + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 } - }, + } + }, + { + "type": "String", + "value": "\"i-use-things\"", "range": [ 15, 29 ], - "type": "String", - "value": "\"i-use-things\"" - }, - { "loc": { - "end": { - "column": 31, - "line": 1 - }, "start": { - "column": 30, - "line": 1 + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 29 } - }, + } + }, + { + "type": "Punctuator", + "value": "{", "range": [ 30, 31 ], - "type": "Punctuator", - "value": "{" - }, - { "loc": { - "end": { - "column": 8, - "line": 2 - }, "start": { - "column": 2, - "line": 2 + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 } - }, + } + }, + { + "type": "Keyword", + "value": "import", "range": [ 34, 40 ], - "type": "Keyword", - "value": "import" - }, - { "loc": { - "end": { - "column": 11, - "line": 2 - }, "start": { - "column": 9, - "line": 2 + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 } - }, + } + }, + { + "type": "Identifier", + "value": "fs", "range": [ 41, 43 ], - "type": "Identifier", - "value": "fs" - }, - { "loc": { - "end": { - "column": 16, - "line": 2 - }, "start": { - "column": 12, - "line": 2 + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 } - }, + } + }, + { + "type": "Identifier", + "value": "from", "range": [ 44, 48 ], - "type": "Identifier", - "value": "from" - }, - { "loc": { - "end": { - "column": 21, - "line": 2 - }, "start": { - "column": 17, - "line": 2 + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 16 } - }, + } + }, + { + "type": "String", + "value": "'fs'", "range": [ 49, 53 ], - "type": "String", - "value": "'fs'" - }, - { "loc": { - "end": { - "column": 22, - "line": 2 - }, "start": { - "column": 21, - "line": 2 + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 21 } - }, + } + }, + { + "type": "Punctuator", + "value": ";", "range": [ 53, 54 ], - "type": "Punctuator", - "value": ";" - }, - { "loc": { - "end": { - "column": 1, - "line": 3 - }, "start": { - "column": 0, - "line": 3 + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 } - }, + } + }, + { + "type": "Punctuator", + "value": "}", "range": [ 55, 56 ], - "type": "Punctuator", - "value": "}" + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } } - ], - "type": "Program" -} + ] +}; \ No newline at end of file diff --git a/tests/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.result.js b/tests/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.result.js index 5d7507c..9bee7fd 100644 --- a/tests/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.result.js +++ b/tests/fixtures/typescript/namespaces-and-modules/declare-namespace-with-exported-function.result.js @@ -230,59 +230,58 @@ module.exports = { "name": "Selection" }, "typeParameters": { + "type": "TypeParameterInstantiation", + "range": [ + 76, + 81 + ], "loc": { - "end": { - "column": 58, - "line": 2 - }, "start": { - "column": 53, - "line": 2 + "line": 2, + "column": 53 + }, + "end": { + "line": 2, + "column": 58 } }, "params": [ { - "id": { - "loc": { - "end": { - "column": 57, - "line": 2 - }, - "start": { - "column": 54, - "line": 2 - } + "type": "GenericTypeAnnotation", + "range": [ + 77, + 80 + ], + "loc": { + "start": { + "line": 2, + "column": 54 }, + "end": { + "line": 2, + "column": 57 + } + }, + "id": { + "type": "TSAnyKeyword", "range": [ 77, 80 ], - "type": "TSAnyKeyword" - }, - - "loc": { - "end": { - "column": 57, - "line": 2 - }, - "start": { - "column": 54, - "line": 2 + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 2, + "column": 57 + } } }, - "range": [ - 77, - 80 - ], - "type": "GenericTypeAnnotation", "typeParameters": null } - ], - "range": [ - 76, - 81 - ], - "type": "TypeParameterInstantiation" + ] } } } @@ -653,4 +652,4 @@ module.exports = { } } ] -}; +}; \ No newline at end of file