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

Method instanceClassOf

ark/aot/graph.ts:6054–6076  ·  view source on GitHub ↗
(
		node: Node,
		module: SourceModule
	)

Source from the content-addressed store, hash-verified

6052 // e.g. `Store` of `class Store {}`, unless the program may change it, or
6053 // one a package exports where the build reads the whole program
6054 private instanceClassOf(
6055 node: Node,
6056 module: SourceModule
6057 ): [Class, SourceModule] | undefined {
6058 node = unwrapChain(node)
6059 const binding = module.scopes.byId.get(node)?.binding
6060 if (binding?.kind === "class") {
6061 return (
6062 readsOnlyMembers(binding) &&
6063 !this.writesThrough(binding, module).length
6064 ) ?
6065 [binding.declaration as Class, module]
6066 : undefined
6067 }
6068 const definition = this.view && this.definitionOf(node, module)
6069 return (
6070 definition &&
6071 (definition[0].type === "ClassDeclaration" ||
6072 definition[0].type === "ClassExpression")
6073 ) ?
6074 (definition as [Class, SourceModule])
6075 : undefined
6076 }
6077
6078 // the function or class a value names, read through a package's modules:
6079 // e.g. `register` of `import { register } from "registry"`, or

Callers 1

instanceMethodOfMethod · 0.95

Calls 5

writesThroughMethod · 0.95
definitionOfMethod · 0.95
unwrapChainFunction · 0.90
readsOnlyMembersFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected