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

Commit 8b97fe7

Browse files
JamesHenrynzakas
authored andcommitted
New: Add class decorators to AST (fixes #66) (#67)
1 parent 7364cb9 commit 8b97fe7

File tree

49 files changed

+715
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+715
-12
lines changed

lib/ast-converter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,10 @@ module.exports = function(ast, extra) {
13171317
loc: getLocFor(openBrace.getStart(), node.end, ast)
13181318
},
13191319
superClass: (superClass ? convertChild(superClass.types[0].expression) : null),
1320-
implements: hasImplements ? heritageClauses[0].types.map(convertClassImplements) : []
1320+
implements: hasImplements ? heritageClauses[0].types.map(convertClassImplements) : [],
1321+
decorators: (node.decorators) ? node.decorators.map(function(d) {
1322+
return convertChild(d.expression);
1323+
}) : []
13211324
});
13221325

13231326
var filteredMembers = node.members.filter(isESTreeClassMember);

tests/fixtures/attach-comments/export-default-anonymous-class.result.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportDefaultDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": null,
910
"superClass": null,
1011
"implements": [],

tests/fixtures/ecma-features-mix/classes-and-generators/classes-and-generators.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"body": [
44
{
55
"type": "ClassDeclaration",
6+
"decorators": [],
67
"id": {
78
"type": "Identifier",
89
"name": "Foo",
@@ -331,4 +332,4 @@ module.exports = {
331332
}
332333
}
333334
]
334-
};
335+
};

tests/fixtures/ecma-features-mix/classes-and-generators/computed-generator.result.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"body": [
44
{
55
"type": "ClassDeclaration",
6+
"decorators": [],
67
"id": {
78
"type": "Identifier",
89
"name": "Foo",

tests/fixtures/ecma-features-mix/classes-and-generators/static-generators.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"body": [
44
{
55
"type": "ClassDeclaration",
6+
"decorators": [],
67
"id": {
78
"type": "Identifier",
89
"name": "Foo",
@@ -349,4 +350,4 @@ module.exports = {
349350
}
350351
}
351352
]
352-
};
353+
};

tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous-extends.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportDefaultDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": null,
910
"superClass": {
1011
"type": "Identifier",
@@ -251,4 +252,4 @@ module.exports = {
251252
}
252253
}
253254
]
254-
};
255+
};

tests/fixtures/ecma-features-mix/modules-and-classes/class-default-anonymous.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportDefaultDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": null,
910
"superClass": null,
1011
"body": {
@@ -198,4 +199,4 @@ module.exports = {
198199
}
199200
}
200201
]
201-
};
202+
};

tests/fixtures/ecma-features-mix/modules-and-classes/class-default-extends.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportDefaultDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": {
910
"type": "Identifier",
1011
"name": "foo",
@@ -286,4 +287,4 @@ module.exports = {
286287
}
287288
}
288289
]
289-
};
290+
};

tests/fixtures/ecma-features-mix/modules-and-classes/class-default.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportDefaultDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": {
910
"type": "Identifier",
1011
"name": "foo",
@@ -233,4 +234,4 @@ module.exports = {
233234
}
234235
}
235236
]
236-
};
237+
};

tests/fixtures/ecma-features-mix/modules-and-classes/class-extends.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
"type": "ExportNamedDeclaration",
66
"declaration": {
77
"type": "ClassDeclaration",
8+
"decorators": [],
89
"id": {
910
"type": "Identifier",
1011
"name": "foo",
@@ -270,4 +271,4 @@ module.exports = {
270271
}
271272
}
272273
]
273-
};
274+
};

0 commit comments

Comments
 (0)