Debian Codegraph @

packages/babel-helper-member-expression-to-functions/src/index.ts

raw symbols SCIP
1 import type { NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, Visitorscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/Visitor# } from "@babel/traverse"scip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/;
2 import {
3 LOGICAL_OPERATORSscip-typescript npm @babel/types 7.20.7 src/constants/`index.ts`/LOGICAL_OPERATORS.,
4 arrowFunctionExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/arrowFunctionExpression().,
5 assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().,
6 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().,
7 booleanLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/booleanLiteral().,
8 callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().,
9 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().,
10 conditionalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/conditionalExpression().,
11 identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().,
12 isMemberExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMemberExpression().,
13 isOptionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isOptionalCallExpression().,
14 isOptionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isOptionalMemberExpression().,
15 isUpdateExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isUpdateExpression().,
16 logicalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/logicalExpression().,
17 memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().,
18 nullLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/nullLiteral().,
19 optionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/optionalCallExpression().,
20 optionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/optionalMemberExpression().,
21 sequenceExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/sequenceExpression().,
22 updateExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/updateExpression().,
23 } from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/;
24 import type * as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/ from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/;
25 import { willPathCastToBooleanscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`util.ts`/willPathCastToBoolean(). } from "./util"scip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`util.ts`/;
26
27 class AssignmentMemoiserscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser# {
28 private _mapscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.: WeakMapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#, { countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:count.: number; valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:value.: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# }>;
29 constructorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#`<constructor>`().() {
30 this._mapscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map. = new WeakMapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#();
31 }
32
33 hasscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#has().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#has().(key): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#) {
34 return this._mapscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map..hasscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#has().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#has().(key));
35 }
36
37 getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#get().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#get().(key): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#) {
38 if (!this.hasscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#has().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#get().(key))) return;
39
40 const record = this._mapscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map..getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#get().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#get().(key));
41 const { valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:value. } = record;
42
43 record.countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:count.--;
44 if (record.countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:count. === 0) {
45 // The `count` access is the outermost function call (hopefully), so it
46 // does the assignment.
47 return assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", value, keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#get().(key));
48 }
49 return value;
50 }
51
52 setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#set().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#set().(key): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#, valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#set().(value): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#, countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#set().(count): number) {
53 return this._mapscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map..setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#set().(keyscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#set().(key), { countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:count., valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#_map.WeakMap:typeLiteral0:value. });
54 }
55 }
56
57 function toNonOptionalscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(
58 pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#>,
59 basescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(base): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#,
60 ): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression# {
61 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. } = pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path);
62 if (isOptionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isOptionalMemberExpression().(node)) {
63 return memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(basescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(base), node.propertyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#property., node.computedscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#computed.);
64 }
65
66 if (pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).isOptionalCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalCallExpression().()) {
67 const callee = pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).get("callee");
68 if (pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#optional. && callee.isOptionalMemberExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalMemberExpression().()) {
69 // object must be a conditional expression because the optional private access in object has been transformed
70 const object = callee.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..objectscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#object. as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ConditionalExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ConditionalExpression#;
71 const context = pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..maybeGenerateMemoisedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(object);
72 callee
73 .get("object")
74 .replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", context, object));
75
76 return callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(basescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(base), identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("call")), [
77 context,
78 ...pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.,
79 ]);
80 }
81
82 return callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(basescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(base), pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.);
83 }
84
85 return pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(path).nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
86 }
87
88 // Determines if the current path is in a detached tree. This can happen when
89 // we are iterating on a path, and replace an ancestor with a new node. Babel
90 // doesn't always stop traversing the old node tree, and that can cause
91 // inconsistencies.
92 function isInDetachedTreescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) {
93 while (pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(path)) {
94 if (pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(path).isProgramscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isProgram().()) break;
95
96 const { parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath., containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container., listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#listKey. } = pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(path);
97 const parentNode = parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
98 if (listKey) {
99 if (
100 container !==
101 // @ts-expect-error listKey must be a valid parent node key
102 parentNode[listKey]
103 ) {
104 return true;
105 }
106 } else {
107 if (container !== parentNode) return true;
108 }
109
110 pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(path) = parentPath;
111 }
112
113 return false;
114 }
115
116 type Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member# = NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.OptionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.MemberExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/MemberExpression#>;
117
118 const handlescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/handle. = {
119 memoise() {
120 // noop.
121 },
122
123 handle(this: HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#, member: Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#, noDocumentAll: boolean) {
124 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent., parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath., scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = member;
125
126 if (member.isOptionalMemberExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalMemberExpression().()) {
127 // Transforming optional chaining requires we replace ancestors.
128 if (isInDetachedTreescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/isInDetachedTree().(member)) return;
129
130 // We're looking for the end of _this_ optional chain, which is actually
131 // the "rightmost" property access of the chain. This is because
132 // everything up to that property access is "optional".
133 //
134 // Let's take the case of `FOO?.BAR.baz?.qux`, with `FOO?.BAR` being our
135 // member. The "end" to most users would be `qux` property access.
136 // Everything up to it could be skipped if it `FOO` were nullish. But
137 // actually, we can consider the `baz` access to be the end. So we're
138 // looking for the nearest optional chain that is `optional: true`.
139 const endPath = member.findscip-typescript npm @babel/traverse 7.20.13 src/path/`ancestry.ts`/find().(({ nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent. }) => {
140 if (isOptionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isOptionalMemberExpression().(parent)) {
141 // We need to check `parent.object` since we could be inside the
142 // computed expression of a `bad?.[FOO?.BAR]`. In this case, the
143 // endPath is the `FOO?.BAR` member itself.
144 return parent.optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#optional. || parent.objectscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#object. !== node;
145 }
146 if (isOptionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isOptionalCallExpression().(parent)) {
147 // Checking `parent.callee` since we could be in the arguments, eg
148 // `bad?.(FOO?.BAR)`.
149 // Also skip `FOO?.BAR` in `FOO?.BAR?.()` since we need to transform the optional call to ensure proper this
150 return (
151 // In FOO?.#BAR?.(), endPath points the optional call expression so we skip FOO?.#BAR
152 (node !== member.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. && parent.optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#optional.) || parent.calleescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#callee. !== node
153 );
154 }
155 return true;
156 }) as NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.OptionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#>;
157
158 // Replace `function (a, x = a.b?.#c) {}` to `function (a, x = (() => a.b?.#c)() ){}`
159 // so the temporary variable can be injected in correct scope
160 // This can be further optimized to avoid unecessary IIFE
161 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().()) {
162 endPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
163 // The injected member will be queued and eventually transformed when visited
164 callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(arrowFunctionExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/arrowFunctionExpression().([], endPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.), []),
165 );
166 return;
167 }
168
169 const willEndPathCastToBoolean = willPathCastToBooleanscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`util.ts`/willPathCastToBoolean().(endPath);
170
171 const rootParentPath = endPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.;
172 if (
173 rootParentPath.isUpdateExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isUpdateExpression().({ argumentscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/argument0:: node }) ||
174 rootParentPath.isAssignmentExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isAssignmentExpression().({ leftscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/left0:: node })
175 ) {
176 throw member.buildCodeFrameErrorscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#buildCodeFrameError().(`can't handle assignment`);
177 }
178 const isDeleteOperation = rootParentPath.isUnaryExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isUnaryExpression().({
179 operatorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/operator0:: "delete",
180 });
181 if (
182 isDeleteOperation &&
183 endPath.isOptionalMemberExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalMemberExpression().() &&
184 endPath.get("property").isPrivateNamescip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPrivateName().()
185 ) {
186 // @babel/parser will throw error on `delete obj?.#x`.
187 // This error serves as fallback when `delete obj?.#x` is constructed from babel types
188 throw member.buildCodeFrameErrorscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#buildCodeFrameError().(
189 `can't delete a private class element`,
190 );
191 }
192
193 // Now, we're looking for the start of this optional chain, which is
194 // optional to the left of this member.
195 //
196 // Let's take the case of `foo?.bar?.baz.QUX?.BAM`, with `QUX?.BAM` being
197 // our member. The "start" to most users would be `foo` object access.
198 // But actually, we can consider the `bar` access to be the start. So
199 // we're looking for the nearest optional chain that is `optional: true`,
200 // which is guaranteed to be somewhere in the object/callee tree.
201 let startingOptional: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#> = member;
202 for (;;) {
203 if (startingOptional.isOptionalMemberExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalMemberExpression().()) {
204 if (startingOptional.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalMemberExpression#optional.) break;
205 startingOptional = startingOptional.get("object");
206 continue;
207 } else if (startingOptional.isOptionalCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalCallExpression().()) {
208 if (startingOptional.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#optional.) break;
209 startingOptional = startingOptional.get("callee");
210 continue;
211 }
212 // prevent infinite loop: unreachable if the AST is well-formed
213 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
214 `Internal error: unexpected ${startingOptional.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.}`,
215 );
216 }
217
218 // @ts-expect-error isOptionalMemberExpression does not work with NodePath union
219 const startingNode = startingOptional.isOptionalMemberExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalMemberExpression().()
220 ? // @ts-expect-error isOptionalMemberExpression does not work with NodePath union
221 startingOptional.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..object
222 : // @ts-expect-error isOptionalMemberExpression does not work with NodePath union
223 startingOptional.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..callee;
224 const baseNeedsMemoised = scope.maybeGenerateMemoisedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(startingNode);
225 const baseRef = baseNeedsMemoised ?? startingNode;
226
227 // Compute parentIsOptionalCall before `startingOptional` is replaced
228 // as `node` may refer to `startingOptional.node` before replaced.
229 const parentIsOptionalCall = parentPath.isOptionalCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalCallExpression().({
230 calleescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/callee0:: node,
231 });
232 // here we use a function to wrap `parentIsOptionalCall` to get type
233 // for parent, do not use it anywhere else
234 // See https://github.com/microsoft/TypeScript/issues/10421
235 const isOptionalCall = (
236 parent: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#,
237 ): parent is tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.OptionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression# => parentIsOptionalCall;
238 // if parentIsCall is true, it implies that node.extra.parenthesized is always true
239 const parentIsCall = parentPath.isCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isCallExpression().({ calleescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/callee1:: node });
240 startingOptional.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(toNonOptionalscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(startingOptional, baseRef));
241 if (isOptionalCall(parent)) {
242 if (parent.optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#optional.) {
243 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.optionalCallscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(member, parent.argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.));
244 } else {
245 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.callscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(member, parent.argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.));
246 }
247 } else if (parentIsCall) {
248 // `(a?.#b)()` to `(a == null ? void 0 : a.#b.bind(a))()`
249 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.boundGetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#boundGet().(member));
250 } else if (
251 this.deletescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete(). &&
252 parentPath.isUnaryExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isUnaryExpression().({ operatorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/operator1:: "delete" })
253 ) {
254 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.deletescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete().(member));
255 } else {
256 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member));
257 }
258
259 let regular: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression# = member.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
260 for (let current: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# = member; current !== endPath; ) {
261 const parentPath = current.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath. as NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#>;
262 // skip transforming `Foo.#BAR?.call(FOO)`
263 if (
264 parentPath === endPath &&
265 isOptionalCall(parent) &&
266 parent.optionalscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#optional.
267 ) {
268 regular = parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
269 break;
270 }
271 regular = toNonOptionalscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/toNonOptional().(parentPath, regular);
272 current = parentPath;
273 }
274
275 let context: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#;
276 const endParentPath = endPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath. as NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#>;
277 if (
278 isMemberExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isMemberExpression().(regular) &&
279 endParentPath.isOptionalCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalCallExpression().({
280 calleescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/callee2:: endPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.,
281 optionalscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/optional0:: true,
282 })
283 ) {
284 const { objectscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/MemberExpression#object. } = regular;
285 context = member.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..maybeGenerateMemoisedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(object);
286 if (context) {
287 regular.objectscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/MemberExpression#object. = assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().(
288 "=",
289 context,
290 // object must not be Super when `context` is an identifier
291 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
292 object as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#,
293 );
294 }
295 }
296
297 let replacementPath: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# = endPath;
298 if (isDeleteOperation) {
299 replacementPath = endParentPath;
300 regular = endParentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
301 }
302
303 const baseMemoised = baseNeedsMemoised
304 ? assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().(
305 "=",
306 // When base needs memoised, the baseRef must be an identifier
307 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(baseRef as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#),
308 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(startingNode),
309 )
310 : cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(baseRef);
311
312 if (willEndPathCastToBoolean) {
313 let nonNullishCheck;
314 if (noDocumentAll) {
315 nonNullishCheck = binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().("!=", baseMemoised, nullLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/nullLiteral().());
316 } else {
317 nonNullishCheck = logicalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/logicalExpression().(
318 "&&",
319 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().("!==", baseMemoised, nullLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/nullLiteral().()),
320 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().(
321 "!==",
322 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(baseRef),
323 scope.buildUndefinedNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#buildUndefinedNode().(),
324 ),
325 );
326 }
327 replacementPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
328 logicalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/logicalExpression().("&&", nonNullishCheck, regular),
329 );
330 } else {
331 let nullishCheck;
332 if (noDocumentAll) {
333 nullishCheck = binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().("==", baseMemoised, nullLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/nullLiteral().());
334 } else {
335 nullishCheck = logicalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/logicalExpression().(
336 "||",
337 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().("===", baseMemoised, nullLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/nullLiteral().()),
338 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().(
339 "===",
340 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(baseRef),
341 scope.buildUndefinedNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#buildUndefinedNode().(),
342 ),
343 );
344 }
345
346 replacementPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
347 conditionalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/conditionalExpression().(
348 nullishCheck,
349 isDeleteOperation
350 ? booleanLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/booleanLiteral().(true)
351 : scope.buildUndefinedNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#buildUndefinedNode().(),
352 regular,
353 ),
354 );
355 }
356
357 // context and isDeleteOperation can not be both truthy
358 if (context) {
359 const endParent = endParentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.OptionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#;
360 endParentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
361 optionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/optionalCallExpression().(
362 optionalMemberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/optionalMemberExpression().(
363 endParent.calleescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#callee.,
364 identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("call"),
365 false,
366 true,
367 ),
368 [cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(context), ...endParent.argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.],
369 false,
370 ),
371 );
372 }
373
374 return;
375 }
376
377 // MEMBER++ -> _set(MEMBER, (ref = _get(MEMBER), ref2 = ref++, ref)), ref2
378 // ++MEMBER -> _set(MEMBER, (ref = _get(MEMBER), ++ref))
379 if (isUpdateExpressionscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isUpdateExpression().(parent, { argumentscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/argument1:: node })) {
380 if (this.simpleSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().) {
381 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.simpleSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().(member));
382 return;
383 }
384
385 const { operatorscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/UpdateExpression#operator., prefixscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/UpdateExpression#prefix. } = parent;
386
387 // Give the state handler a chance to memoise the member, since we'll
388 // reference it twice. The second access (the set) should do the memo
389 // assignment.
390 this.memoisescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(member, 2);
391
392 const ref = scope.generateUidIdentifierBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(node);
393 scope.pushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().({ idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id.: ref });
394
395 const seq: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#[] = [
396 // ref = _get(MEMBER)
397 assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref), this.getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member)),
398 ];
399
400 if (prefix) {
401 seq.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(updateExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/updateExpression().(operator, cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref), prefix));
402
403 // (ref = _get(MEMBER), ++ref)
404 const value = sequenceExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/sequenceExpression().(seq);
405 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(member, value));
406
407 return;
408 } else {
409 const ref2 = scope.generateUidIdentifierBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(node);
410 scope.pushscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().({ idscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#push().(opts)typeLiteral191:id.: ref2 });
411
412 seq.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(
413 assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().(
414 "=",
415 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref2),
416 updateExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/updateExpression().(operator, cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref), prefix),
417 ),
418 cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref),
419 );
420
421 // (ref = _get(MEMBER), ref2 = ref++, ref)
422 const value = sequenceExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/sequenceExpression().(seq);
423 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
424 sequenceExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/sequenceExpression().([this.setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(member, value), cloneNodescip-typescript npm @babel/types 7.20.7 src/clone/`cloneNode.ts`/cloneNode().(ref2)]),
425 );
426
427 return;
428 }
429 }
430
431 // MEMBER = VALUE -> _set(MEMBER, VALUE)
432 // MEMBER += VALUE -> _set(MEMBER, _get(MEMBER) + VALUE)
433 // MEMBER ??= VALUE -> _get(MEMBER) ?? _set(MEMBER, VALUE)
434 if (parentPath.isAssignmentExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isAssignmentExpression().({ leftscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/left1:: node })) {
435 if (this.simpleSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().) {
436 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.simpleSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().(member));
437 return;
438 }
439
440 const { operatorscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/AssignmentExpression#operator., rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/AssignmentExpression#right.: value } = parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
441
442 if (operator === "=") {
443 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(member, value));
444 } else {
445 const operatorTrunc = operator.slicescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#slice().(0, -1);
446 if (LOGICAL_OPERATORSscip-typescript npm @babel/types 7.20.7 src/constants/`index.ts`/LOGICAL_OPERATORS..includesscip-typescript npm typescript 5.9.3 lib/`lib.es2016.array.include.d.ts`/Array#includes().(operatorTrunc)) {
447 // Give the state handler a chance to memoise the member, since we'll
448 // reference it twice. The first access (the get) should do the memo
449 // assignment.
450 this.memoisescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(member, 1);
451 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
452 logicalExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/logicalExpression().(
453 operatorTrunc as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.LogicalExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LogicalExpression#["operator"scip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LogicalExpression#operator.],
454 this.getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member),
455 this.setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(member, value),
456 ),
457 );
458 } else {
459 // Here, the second access (the set) is evaluated first.
460 this.memoisescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(member, 2);
461 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
462 this.setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(
463 member,
464 binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().(
465 operatorTrunc as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.BinaryExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BinaryExpression#["operator"scip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BinaryExpression#operator.],
466 this.getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member),
467 value,
468 ),
469 ),
470 );
471 }
472 }
473 return;
474 }
475
476 // MEMBER(ARGS) -> _call(MEMBER, ARGS)
477 if (parentPath.isCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isCallExpression().({ calleescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/callee3:: node })) {
478 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.callscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(member, parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/CallExpression#arguments.));
479 return;
480 }
481
482 // MEMBER?.(ARGS) -> _optionalCall(MEMBER, ARGS)
483 if (parentPath.isOptionalCallExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isOptionalCallExpression().({ calleescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/callee4:: node })) {
484 // Replace `function (a, x = a.b.#c?.()) {}` to `function (a, x = (() => a.b.#c?.())() ){}`
485 // so the temporary variable can be injected in correct scope
486 // This can be further optimized to avoid unecessary IIFE
487 if (scope.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#path..isPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isPattern().()) {
488 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
489 // The injected member will be queued and eventually transformed when visited
490 callExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/callExpression().(arrowFunctionExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/arrowFunctionExpression().([], parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.), []),
491 );
492 return;
493 }
494 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
495 this.optionalCallscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(member, parentPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..argumentsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.),
496 );
497 return;
498 }
499
500 // delete MEMBER -> _delete(MEMBER)
501 if (this.deletescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete(). && parentPath.isUnaryExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isUnaryExpression().({ operatorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/operator2:: "delete" })) {
502 parentPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.deletescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete().(member));
503 return;
504 }
505
506 // for (MEMBER of ARR)
507 // for (MEMBER in ARR)
508 // { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ
509 // { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ
510 // {...MEMBER} -> {..._destructureSet(MEMBER)}
511 //
512 // [MEMBER] = ARR -> [_destructureSet(MEMBER)] = ARR
513 // [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR
514 // [...MEMBER] -> [..._destructureSet(MEMBER)]
515 if (
516 // for (MEMBER of ARR)
517 // for (MEMBER in ARR)
518 parentPath.isForXStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isForXStatement().({ leftscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/left2:: node }) ||
519 // { KEY: MEMBER } = OBJ
520 (parentPath.isObjectPropertyscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isObjectProperty().({ valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/value0:: node }) &&
521 parentPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..isObjectPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isObjectPattern().()) ||
522 // { KEY: MEMBER = _VALUE } = OBJ
523 (parentPath.isAssignmentPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isAssignmentPattern().({ leftscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/left3:: node }) &&
524 parentPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..isObjectPropertyscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isObjectProperty().({ valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/value1:: parent }) &&
525 parentPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..isObjectPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isObjectPattern().()) ||
526 // [MEMBER] = ARR
527 parentPath.isArrayPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isArrayPattern().() ||
528 // [MEMBER = _VALUE] = ARR
529 (parentPath.isAssignmentPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isAssignmentPattern().({ leftscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/left4:: node }) &&
530 parentPath.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..isArrayPatternscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isArrayPattern().()) ||
531 // {...MEMBER}
532 // [...MEMBER]
533 parentPath.isRestElementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isRestElement().()
534 ) {
535 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.destructureSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#destructureSet().(member));
536 return;
537 }
538
539 if (parentPath.isTaggedTemplateExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isTaggedTemplateExpression().()) {
540 // MEMBER -> _get(MEMBER).bind(this)
541 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.boundGetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#boundGet().(member));
542 } else {
543 // MEMBER -> _get(MEMBER)
544 member.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(this.getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member));
545 }
546 },
547 };
548
549 export interface Handlerscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> {
550 memoisescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().?(
551 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State],
552 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
553 countscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#memoise().(count): number,
554 ): void;
555 destructureSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#destructureSet().(
556 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#destructureSet().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State],
557 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#destructureSet().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
558 ): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
559 boundGetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#boundGet().(thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#boundGet().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State], memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#boundGet().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
560 simpleSetscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().?(thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State], memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#simpleSet().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
561 getscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State], memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#get().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
562 setscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(
563 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State],
564 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
565 valuescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#set().(value): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#,
566 ): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
567 callscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(
568 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State],
569 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
570 argsscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#call().(args): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.CallExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/CallExpression#["arguments"scip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/CallExpression#arguments.],
571 ): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
572 optionalCallscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(
573 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State],
574 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
575 argsscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#optionalCall().(args): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.OptionalCallExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#["arguments"scip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/OptionalCallExpression#arguments.],
576 ): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
577 // TODO(Babel 8): Consider making this required, since `.get` doesn't
578 // really work as a fallback for `.delete`
579 deletescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete().?(thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#[State], memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#delete().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#;
580 }
581
582 export interface HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#[State] = {}> extends Handlerscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#[State]> {
583 handlescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#handle().(
584 thisscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#handle().(this): HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#[State]> & Statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#[State],
585 memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#handle().(member): Memberscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Member#,
586 noDocumentAllscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#handle().(noDocumentAll)?: boolean,
587 ): void;
588 memoiserscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#memoiser.: AssignmentMemoiserscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#;
589 }
590
591 // We do not provide a default traversal visitor
592 // Instead, caller passes one, and must call `state.handle` on the members
593 // it wishes to be transformed.
594 // Additionally, the caller must pass in a state object with at least
595 // get, set, and call methods.
596 // Optionally, a memoise method may be defined on the state, which will be
597 // called when the member is a self-referential update.
598 export default function memberExpressionToFunctionsscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().<CustomStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().[CustomState] = {}>(
599 pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#,
600 visitorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(visitor): Visitorscip-typescript npm @babel/traverse 7.20.13 src/`types.ts`/Visitor#<HandlerStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#<CustomStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().[CustomState]>>,
601 statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(state): Handlerscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/Handler#<CustomStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().[CustomState]> & CustomStatescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().[CustomState],
602 ) {
603 pathscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(path).traversescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#traverse().(visitorscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(visitor), {
604 ...handlescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/handle.,
605 ...statescip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/memberExpressionToFunctions().(state),
606 memoiserscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/HandlerState#memoiser.: new AssignmentMemoiserscip-typescript npm @babel/helper-member-expression-to-functions 7.20.7 src/`index.ts`/AssignmentMemoiser#`<constructor>`().(),
607 });
608 }