| 1 |
import { declare } from "@babel/helper-plugin-utils"; |
| 2 |
import { transform } from "@babel/plugin-proposal-optional-chaining"; |
| 3 |
import { shouldTransform } from "./util"; |
| 4 |
import type { NodePath } from "@babel/traverse"; |
| 5 |
import type * as t from "@babel/types"; |
| 6 |
|
| 7 |
export default declare(api => { |
| 8 |
api.assertVersion(7); |
| 9 |
|
| 10 |
const noDocumentAll = api.assumption("noDocumentAll") ?? false; |
| 11 |
const pureGetters = api.assumption("pureGetters") ?? false; |
| 12 |
|
| 13 |
return { |
| 14 |
name: "bugfix-v8-spread-parameters-in-optional-chaining", |
| 15 |
|
| 16 |
visitor: { |
| 17 |
"OptionalCallExpression|OptionalMemberExpression"( |
| 18 |
path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>, |
| 19 |
) { |
| 20 |
if (shouldTransform(path)) { |
| 21 |
transform(path, { noDocumentAll, pureGetters }); |
| 22 |
} |
| 23 |
}, |
| 24 |
}, |
| 25 |
}; |
| 26 |
}); |