-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathplugin.ts
More file actions
29 lines (27 loc) · 801 Bytes
/
Copy pathplugin.ts
File metadata and controls
29 lines (27 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { PluginObj } from '@babel/core';
import { declare } from '@babel/helper-plugin-utils';
import { transform } from './transform';
export default declare(
(api: any): PluginObj => {
api.assertVersion(7);
return {
visitor: {
Program(programPath) {
/**
* We need to traverse the program right here since
* `@babel/preset-typescript` removes imports at this level.
*
* Since we need to convert some typings into **bindings**, used in
* `Reflect.metadata` calls, we need to process them **before**
* the typescript preset.
*/
programPath.traverse({
ClassDeclaration(path) {
transform(path);
}
});
}
}
};
}
);