( node: ObjectPattern, bindings: Record<string, BindingTypes>, isConst: boolean, isDefineCall = false, )
| 1232 | } |
| 1233 | |
| 1234 | function walkObjectPattern( |
| 1235 | node: ObjectPattern, |
| 1236 | bindings: Record<string, BindingTypes>, |
| 1237 | isConst: boolean, |
| 1238 | isDefineCall = false, |
| 1239 | ) { |
| 1240 | for (const p of node.properties) { |
| 1241 | if (p.type === 'ObjectProperty') { |
| 1242 | if (p.key.type === 'Identifier' && p.key === p.value) { |
| 1243 | // shorthand: const { x } = ... |
| 1244 | const type = isDefineCall |
| 1245 | ? BindingTypes.SETUP_CONST |
| 1246 | : isConst |
| 1247 | ? BindingTypes.SETUP_MAYBE_REF |
| 1248 | : BindingTypes.SETUP_LET |
| 1249 | registerBinding(bindings, p.key, type) |
| 1250 | } else { |
| 1251 | walkPattern(p.value, bindings, isConst, isDefineCall) |
| 1252 | } |
| 1253 | } else { |
| 1254 | // ...rest |
| 1255 | // argument can only be identifier when destructuring |
| 1256 | const type = isConst ? BindingTypes.SETUP_CONST : BindingTypes.SETUP_LET |
| 1257 | registerBinding(bindings, p.argument as Identifier, type) |
| 1258 | } |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | function walkArrayPattern( |
| 1263 | node: ArrayPattern, |
no test coverage detected