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

Method namespaceKindOf

ark/aot/graph.ts:1794–1823  ·  view source on GitHub ↗
(
		binding: Binding,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

1792
1793 // e.g. `N` given `namespace N { export const User = type(...) }`, merged across declarations
1794 private namespaceKindOf(
1795 binding: Binding,
1796 module: SourceModule,
1797 kindOfKey: KindOfKey
1798 ): KindBits {
1799 let held = 0
1800 let isNamespace = false
1801 for (let id of [binding.id, ...binding.writes]) {
1802 while (id.parent?.type === "TSQualifiedName") id = id.parent
1803 const declaration = id.parent
1804 if (declaration?.type !== "TSModuleDeclaration") continue
1805 isNamespace = true
1806 // e.g. `T` in `namespace A.B { export const T = ... }`, read off A
1807 walk(declaration, node => {
1808 if (node.type === "ExportNamedDeclaration" && node.declaration) {
1809 for (const exported of declaredIds(node.declaration)) {
1810 const inner = module.scopes.bindingsById.get(exported)
1811 if (inner) held |= kindOfKey(inner, module)
1812 }
1813 }
1814 return node === declaration || node.type === "TSModuleBlock"
1815 })
1816 }
1817 if (!isNamespace) return 0
1818 for (const write of this.writesThrough(binding, module)) {
1819 if (write.type === "AssignmentExpression")
1820 held |= this.transfer(write.right, module, kindOfKey)
1821 }
1822 return holderOf(held)
1823 }
1824
1825 // e.g. `list.push(A)`, `o.User = A` or `Object.assign(o, { A })`
1826 private storedKindOf(

Callers 1

keyKindOfMethod · 0.95

Calls 6

writesThroughMethod · 0.95
transferMethod · 0.95
walkFunction · 0.90
declaredIdsFunction · 0.90
holderOfFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected