|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import { NodePath, PluginObj, types } from '@babel/core'; |
| 9 | +import type { PluginObj } from '@babel/core'; |
10 | 10 | import annotateAsPure from '@babel/helper-annotate-as-pure';
|
11 | 11 | import * as tslib from 'tslib';
|
12 | 12 |
|
@@ -40,28 +40,28 @@ function isTslibHelperName(name: string): boolean {
|
40 | 40 | export default function (): PluginObj {
|
41 | 41 | return {
|
42 | 42 | visitor: {
|
43 |
| - CallExpression(path: NodePath<types.CallExpression>) { |
| 43 | + CallExpression(path) { |
44 | 44 | // If the expression has a function parent, it is not top-level
|
45 | 45 | if (path.getFunctionParent()) {
|
46 | 46 | return;
|
47 | 47 | }
|
48 | 48 |
|
49 |
| - const callee = path.node.callee; |
| 49 | + const callee = path.get('callee'); |
50 | 50 | if (
|
51 |
| - (types.isFunctionExpression(callee) || types.isArrowFunctionExpression(callee)) && |
| 51 | + (callee.isFunctionExpression() || callee.isArrowFunctionExpression()) && |
52 | 52 | path.node.arguments.length !== 0
|
53 | 53 | ) {
|
54 | 54 | return;
|
55 | 55 | }
|
56 | 56 | // Do not annotate TypeScript helpers emitted by the TypeScript compiler.
|
57 | 57 | // TypeScript helpers are intended to cause side effects.
|
58 |
| - if (types.isIdentifier(callee) && isTslibHelperName(callee.name)) { |
| 58 | + if (callee.isIdentifier() && isTslibHelperName(callee.node.name)) { |
59 | 59 | return;
|
60 | 60 | }
|
61 | 61 |
|
62 | 62 | annotateAsPure(path);
|
63 | 63 | },
|
64 |
| - NewExpression(path: NodePath<types.NewExpression>) { |
| 64 | + NewExpression(path) { |
65 | 65 | // If the expression has a function parent, it is not top-level
|
66 | 66 | if (!path.getFunctionParent()) {
|
67 | 67 | annotateAsPure(path);
|
|
0 commit comments