Skip to content

Commit 51ea628

Browse files
committed
🐛 Minor refinement
1 parent fe63657 commit 51ea628

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/macro.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { transform } from './transform';
33

44
const metadataMacro: MacroHandler = ({ references }) => {
55
references.default.forEach(reference => {
6-
const decorator = reference.findParent(parent => parent.isDecorator())
6+
const decorator = reference.findParent(parent => parent.isDecorator());
77
if (!decorator) {
88
throw new Error("Metadata macro should be used as class decorator");
99
}
@@ -12,10 +12,11 @@ const metadataMacro: MacroHandler = ({ references }) => {
1212
throw new Error("Metadata macro should be used as class decorator");
1313
}
1414
if (classDeclaration.isClassDeclaration()) {
15-
if (classDeclaration.node.decorators) {
16-
classDeclaration.node.decorators = classDeclaration.node.decorators.filter(it => it !== decorator.node);
15+
if (!classDeclaration.node.decorators) {
16+
classDeclaration.node.decorators = [];
1717
}
1818
transform(classDeclaration);
19+
classDeclaration.node.decorators = classDeclaration.node.decorators.filter(it => it !== decorator.node);
1920
}
2021
})
2122
};

src/plugin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { PluginObj } from '@babel/core';
22
import { declare } from '@babel/helper-plugin-utils';
3-
import { parameterVisitor } from './parameter/parameterVisitor';
4-
import { metadataVisitor } from './metadata/metadataVisitor';
53
import { transform } from './transform';
64

75
export default declare(

0 commit comments

Comments
 (0)