forked from babel/babel
/
index.ts
26 lines (22 loc) 路 834 Bytes
/
index.ts
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
import { declare } from "@babel/helper-plugin-utils";
import { transform } from "@babel/plugin-proposal-optional-chaining";
import { shouldTransform } from "./util";
import type { NodePath } from "@babel/traverse";
import type * as t from "@babel/types";
export default declare(api => {
api.assertVersion(7);
const noDocumentAll = (api.assumption("noDocumentAll") ?? false) as boolean;
const pureGetters = (api.assumption("pureGetters") ?? false) as boolean;
return {
name: "bugfix-v8-spread-parameters-in-optional-chaining",
visitor: {
"OptionalCallExpression|OptionalMemberExpression"(
path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>,
) {
if (shouldTransform(path)) {
transform(path, { noDocumentAll, pureGetters });
}
},
},
};
});