diff --git a/lib/ast-converter.js b/lib/ast-converter.js index 3e664ee..b22d597 100644 --- a/lib/ast-converter.js +++ b/lib/ast-converter.js @@ -1317,7 +1317,10 @@ module.exports = function(ast, extra) { loc: getLocFor(openBrace.getStart(), node.end, ast) }, superClass: (superClass ? convertChild(superClass.types[0].expression) : null), - implements: hasImplements ? heritageClauses[0].types.map(convertClassImplements) : [] + implements: hasImplements ? heritageClauses[0].types.map(convertClassImplements) : [], + decorators: (node.decorators) ? node.decorators.map(function(d) { + return convertChild(d.expression); + }) : [] }); var filteredMembers = node.members.filter(isESTreeClassMember); diff --git a/tests/fixtures/attach-comments/export-default-anonymous-class.result.js b/tests/fixtures/attach-comments/export-default-anonymous-class.result.js index 035cd83..d398df2 100644 --- a/tests/fixtures/attach-comments/export-default-anonymous-class.result.js +++ b/tests/fixtures/attach-comments/export-default-anonymous-class.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportDefaultDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": null, "superClass": null, "implements": [], diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/classes-and-generators.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/classes-and-generators.result.js index 8519dad..e453dde 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/classes-and-generators.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/classes-and-generators.result.js @@ -3,6 +3,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "Foo", @@ -331,4 +332,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js index 561edb1..e06db8d 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js @@ -3,6 +3,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "Foo", diff --git a/tests/fixtures/ecma-features-mix/classes-and-generators/static-generators.result.js b/tests/fixtures/ecma-features-mix/classes-and-generators/static-generators.result.js index e90ba96..8b3008d 100644 --- a/tests/fixtures/ecma-features-mix/classes-and-generators/static-generators.result.js +++ b/tests/fixtures/ecma-features-mix/classes-and-generators/static-generators.result.js @@ -3,6 +3,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "Foo", @@ -349,4 +350,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous-extends.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous-extends.result.js index b257935..c9c742e 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous-extends.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous-extends.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportDefaultDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": null, "superClass": { "type": "Identifier", @@ -251,4 +252,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous.result.js index 707bc81..3b3618a 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportDefaultDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": null, "superClass": null, "body": { @@ -198,4 +199,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-extends.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-extends.result.js index 659b026..f726afc 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-extends.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default-extends.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportDefaultDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "foo", @@ -286,4 +287,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default.result.js index 96465b5..7f61b7c 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class-default.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class-default.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportDefaultDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "foo", @@ -233,4 +234,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class-extends.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class-extends.result.js index 0384f13..19809e4 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class-extends.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class-extends.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportNamedDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "foo", @@ -270,4 +271,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features-mix/modules-and-classes/class.result.js b/tests/fixtures/ecma-features-mix/modules-and-classes/class.result.js index 628a1cc..68d44f1 100644 --- a/tests/fixtures/ecma-features-mix/modules-and-classes/class.result.js +++ b/tests/fixtures/ecma-features-mix/modules-and-classes/class.result.js @@ -5,6 +5,7 @@ module.exports = { "type": "ExportNamedDeclaration", "declaration": { "type": "ClassDeclaration", + "decorators": [], "id": { "type": "Identifier", "name": "foo", @@ -217,4 +218,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js b/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js index f0f7cbc..556e8b3 100644 --- a/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js +++ b/tests/fixtures/ecma-features/classes/class-accessor-properties.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js b/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js index c26bbfc..1a9bfa6 100644 --- a/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-computed-static-method.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-expression.result.js b/tests/fixtures/ecma-features/classes/class-expression.result.js index d65bb7b..80b759f 100644 --- a/tests/fixtures/ecma-features/classes/class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/class-expression.result.js @@ -33,6 +33,7 @@ module.exports = { ], "expression": { "type": "ClassExpression", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js b/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js index 14fb1a3..e14f3a8 100644 --- a/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js +++ b/tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-method-named-static.result.js b/tests/fixtures/ecma-features/classes/class-method-named-static.result.js index 935429a..af313d0 100644 --- a/tests/fixtures/ecma-features/classes/class-method-named-static.result.js +++ b/tests/fixtures/ecma-features/classes/class-method-named-static.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-one-method-super.result.js b/tests/fixtures/ecma-features/classes/class-one-method-super.result.js index 867cd1a..09ab5ea 100644 --- a/tests/fixtures/ecma-features/classes/class-one-method-super.result.js +++ b/tests/fixtures/ecma-features/classes/class-one-method-super.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-one-method.result.js b/tests/fixtures/ecma-features/classes/class-one-method.result.js index d328f63..2e2f804 100644 --- a/tests/fixtures/ecma-features/classes/class-one-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-one-method.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js b/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js index 520fce1..7012234 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js b/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js index d208df8..87526a3 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-static-method.result.js b/tests/fixtures/ecma-features/classes/class-static-method.result.js index 368b27a..d1239b2 100644 --- a/tests/fixtures/ecma-features/classes/class-static-method.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-method.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js b/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js index cc4556a..618ca0b 100644 --- a/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js +++ b/tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js b/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js index 83c7099..bdd7db2 100644 --- a/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js index 9f6309f..33903c2 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js index 3780003..dbd94ac 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js index 72029d9..01cd529 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js b/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js index 3dd0d8b..9ca6f81 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-methods.result.js b/tests/fixtures/ecma-features/classes/class-two-methods.result.js index c545cd5..57b2dd6 100644 --- a/tests/fixtures/ecma-features/classes/class-two-methods.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-methods.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js b/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js index ec98ea0..8f75a8b 100644 --- a/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-two-static-methods-named-constructor.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/class-with-constructor.result.js b/tests/fixtures/ecma-features/classes/class-with-constructor.result.js index 6270efa..8150870 100644 --- a/tests/fixtures/ecma-features/classes/class-with-constructor.result.js +++ b/tests/fixtures/ecma-features/classes/class-with-constructor.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js b/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js index 5b3dc08..f0b4ffd 100644 --- a/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js +++ b/tests/fixtures/ecma-features/classes/derived-class-assign-to-var.result.js @@ -68,6 +68,7 @@ module.exports = { }, "init": { "type": "ClassExpression", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/derived-class-expression.result.js b/tests/fixtures/ecma-features/classes/derived-class-expression.result.js index 43e7900..621b72c 100644 --- a/tests/fixtures/ecma-features/classes/derived-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/derived-class-expression.result.js @@ -33,6 +33,7 @@ module.exports = { ], "expression": { "type": "ClassExpression", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js b/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js index f50bdd9..9060a7e 100644 --- a/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class-double-semi.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/empty-class-semi.result.js b/tests/fixtures/ecma-features/classes/empty-class-semi.result.js index 62766a1..4373315 100644 --- a/tests/fixtures/ecma-features/classes/empty-class-semi.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class-semi.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/empty-class.result.js b/tests/fixtures/ecma-features/classes/empty-class.result.js index f50bdd9..9060a7e 100644 --- a/tests/fixtures/ecma-features/classes/empty-class.result.js +++ b/tests/fixtures/ecma-features/classes/empty-class.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js b/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js index 4a18195..3d7aac1 100644 --- a/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js +++ b/tests/fixtures/ecma-features/classes/empty-literal-derived-class.result.js @@ -17,6 +17,7 @@ module.exports = { "body": [ { "type": "ClassDeclaration", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/named-class-expression.result.js b/tests/fixtures/ecma-features/classes/named-class-expression.result.js index f9b682b..ce2fc38 100644 --- a/tests/fixtures/ecma-features/classes/named-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/named-class-expression.result.js @@ -33,6 +33,7 @@ module.exports = { ], "expression": { "type": "ClassExpression", + "decorators": [], "loc": { "start": { "line": 1, diff --git a/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js b/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js index 90666bb..29ae196 100644 --- a/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js +++ b/tests/fixtures/ecma-features/classes/named-derived-class-expression.result.js @@ -33,6 +33,7 @@ module.exports = { ], "expression": { "type": "ClassExpression", + "decorators": [], "loc": { "start": { "line": 1, 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 6dce4c6..f19424b 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 @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ 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 f28bc5d..a368696 100644 --- a/tests/fixtures/typescript/basics/class-with-implements-generic.result.js +++ b/tests/fixtures/typescript/basics/class-with-implements-generic.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ @@ -153,7 +154,7 @@ module.exports = { } }, "name": "S" - }, + } } ] } @@ -326,4 +327,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/typescript/basics/class-with-implements.result.js b/tests/fixtures/typescript/basics/class-with-implements.result.js index 576cfc6..83739b6 100644 --- a/tests/fixtures/typescript/basics/class-with-implements.result.js +++ b/tests/fixtures/typescript/basics/class-with-implements.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ @@ -218,4 +219,4 @@ module.exports = { } } ] -}; \ No newline at end of file +}; diff --git a/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.result.js b/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.result.js new file mode 100644 index 0000000..e99d4c2 --- /dev/null +++ b/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.result.js @@ -0,0 +1,445 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 58 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 58 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "decorators": [ + { + "arguments": [ + { + "loc": { + "end": { + "column": 1, + "line": 3 + }, + "start": { + "column": 11, + "line": 1 + } + }, + "properties": [ + { + "computed": false, + "key": { + "loc": { + "end": { + "column": 12, + "line": 2 + }, + "start": { + "column": 4, + "line": 2 + } + }, + "name": "selector", + "range": [ + 17, + 25 + ], + "type": "Identifier" + }, + "kind": "init", + "loc": { + "end": { + "column": 19, + "line": 2 + }, + "start": { + "column": 4, + "line": 2 + } + }, + "method": false, + "range": [ + 17, + 32 + ], + "shorthand": false, + "type": "Property", + "value": { + "loc": { + "end": { + "column": 19, + "line": 2 + }, + "start": { + "column": 14, + "line": 2 + } + }, + "range": [ + 27, + 32 + ], + "raw": "'foo'", + "type": "Literal", + "value": "foo" + } + } + ], + "range": [ + 11, + 35 + ], + "type": "ObjectExpression" + } + ], + "callee": { + "loc": { + "end": { + "column": 10, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 + } + }, + "name": "Component", + "range": [ + 1, + 10 + ], + "type": "Identifier" + }, + "loc": { + "end": { + "column": 2, + "line": 3 + }, + "start": { + "column": 1, + "line": 1 + } + }, + "range": [ + 1, + 36 + ], + "type": "CallExpression" + } + ], + "id": { + "type": "Identifier", + "range": [ + 43, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "name": "FooComponent" + }, + "body": { + "type": "ClassBody", + "body": [], + "range": [ + 56, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 21 + } + } + }, + "superClass": null, + "implements": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "@", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "Identifier", + "value": "Component", + "range": [ + 1, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 10, + 11 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 11, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "selector", + "range": [ + 17, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "String", + "value": "'foo'", + "range": [ + 27, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "Keyword", + "value": "class", + "range": [ + 37, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "FooComponent", + "range": [ + 43, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 21 + } + } + } + ] +}; diff --git a/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts b/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts new file mode 100644 index 0000000..8732633 --- /dev/null +++ b/tests/fixtures/typescript/decorators/class-decorators/class-decorator-factory.src.ts @@ -0,0 +1,4 @@ +@Component({ + selector: 'foo', +}) +class FooComponent {} \ No newline at end of file diff --git a/tests/fixtures/typescript/decorators/class-decorators/class-decorator.result.js b/tests/fixtures/typescript/decorators/class-decorators/class-decorator.result.js new file mode 100644 index 0000000..5216798 --- /dev/null +++ b/tests/fixtures/typescript/decorators/class-decorators/class-decorator.result.js @@ -0,0 +1,205 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "decorators": [ + { + "loc": { + "end": { + "column": 7, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 + } + }, + "name": "sealed", + "range": [ + 1, + 7 + ], + "type": "Identifier" + } + ], + "id": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "name": "Qux" + }, + "body": { + "type": "ClassBody", + "body": [], + "range": [ + 18, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "superClass": null, + "implements": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "@", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "Identifier", + "value": "sealed", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Keyword", + "value": "class", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "Qux", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ] +}; diff --git a/tests/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts b/tests/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts new file mode 100644 index 0000000..a72a8ff --- /dev/null +++ b/tests/fixtures/typescript/decorators/class-decorators/class-decorator.src.ts @@ -0,0 +1,2 @@ +@sealed +class Qux {} \ No newline at end of file diff --git a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.result.js b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.result.js index 2811d90..0d2b909 100644 --- a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.result.js +++ b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ diff --git a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.result.js b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.result.js index 75861aa..7467cce 100644 --- a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.result.js +++ b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ diff --git a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.result.js b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.result.js index b91dd2b..b345c0c 100644 --- a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.result.js +++ b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-instance-member.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [ diff --git a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.result.js b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.result.js index 1b3250a..eb6584d 100644 --- a/tests/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.result.js +++ b/tests/fixtures/typescript/decorators/method-decorators/method-decorator-static-member.result.js @@ -31,6 +31,7 @@ module.exports = { "column": 1 } }, + "decorators": [], "id": { "type": "Identifier", "range": [