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

Method bindingLiteralOf

ark/aot/graph.ts:4668–4703  ·  view source on GitHub ↗
(
		binding: Binding,
		module: SourceModule,
		kindOfKey: KindOfKey,
		seen: Set<Node>
	)

Source from the content-addressed store, hash-verified

4666 }
4667
4668 private bindingLiteralOf(
4669 binding: Binding,
4670 module: SourceModule,
4671 kindOfKey: KindOfKey,
4672 seen: Set<Node>
4673 ): Located | undefined {
4674 if (binding.kind === "import") {
4675 return this.targetLiteralOf(
4676 this.importOf(binding, module),
4677 kindOfKey,
4678 seen
4679 )
4680 }
4681 const declaration = binding.declaration
4682 // a literal the program writes holds what the build can't tell
4683 if (binding.writes.length || this.writesThrough(binding, module).length)
4684 return
4685 if (binding.kind === "class")
4686 return { node: declaration, module, kindOfKey }
4687 if (
4688 binding.kind !== "const" ||
4689 declaration.type !== "VariableDeclarator" ||
4690 !declaration.init
4691 )
4692 return
4693 // e.g. `{ User }` for `users` in `const { users } = { users: { User } }`
4694 const held = this.destructuredValueOf(
4695 binding.id,
4696 declaration.id,
4697 { node: declaration.init, module, kindOfKey },
4698 seen
4699 )
4700 return held ?
4701 this.literalOf(held.node, held.module, held.kindOfKey, seen)
4702 : undefined
4703 }
4704
4705 private targetLiteralOf(
4706 target: ImportTarget,

Callers 3

exposedKindOfMethod · 0.95
literalOfMethod · 0.95
targetLiteralOfMethod · 0.95

Calls 5

targetLiteralOfMethod · 0.95
importOfMethod · 0.95
writesThroughMethod · 0.95
destructuredValueOfMethod · 0.95
literalOfMethod · 0.95

Tested by

no test coverage detected