MCPcopy Create free account
hub / github.com/arktypeio/arktype / visitVariables

Method visitVariables

ark/aot/scope.ts:414–439  ·  view source on GitHub ↗
(
		node: Extract<Node, { type: "VariableDeclaration" }>
	)

Source from the content-addressed store, hash-verified

412 }
413
414 private visitVariables(
415 node: Extract<Node, { type: "VariableDeclaration" }>
416 ): void {
417 const kind: BindingKind =
418 node.kind === "var" ? "var"
419 : node.kind === "let" ? "let"
420 : "const"
421 for (const declarator of node.declarations) {
422 declarator.parent = node
423 const scope = kind === "var" ? this.functionScope() : this.scope
424 if (
425 declarator.init &&
426 declarator.id.type === "Identifier" &&
427 scope.bindings[declarator.id.name]?.kind === "var"
428 ) {
429 scope.bindings[declarator.id.name].writes.push(declarator.id)
430 declarator.id.parent = declarator
431 } else
432 this.bindPattern(declarator.id, kind, declarator, declarator, scope)
433 if (node.declare) {
434 for (const id of idsOf(declarator.id))
435 this.bindingsById.get(id)!.isAmbient = true
436 }
437 this.visit(declarator.init, declarator)
438 }
439 }
440
441 private visitExport(
442 node: Extract<Node, { type: "ExportNamedDeclaration" }>

Callers 1

visitMethod · 0.95

Calls 6

functionScopeMethod · 0.95
bindPatternMethod · 0.95
visitMethod · 0.95
idsOfFunction · 0.70
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected