MCPcopy
hub / github.com/vuejs/core / walkObjectPattern

Function walkObjectPattern

packages/compiler-sfc/src/compileScript.ts:1234–1260  ·  view source on GitHub ↗
(
  node: ObjectPattern,
  bindings: Record<string, BindingTypes>,
  isConst: boolean,
  isDefineCall = false,
)

Source from the content-addressed store, hash-verified

1232}
1233
1234function 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
1262function walkArrayPattern(
1263 node: ArrayPattern,

Callers 2

walkDeclarationFunction · 0.85
walkPatternFunction · 0.85

Calls 2

walkPatternFunction · 0.85
registerBindingFunction · 0.70

Tested by

no test coverage detected