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

Method scopeReadOf

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

Source from the content-addressed store, hash-verified

5001
5002 // e.g. `getPlaces().type` or `.params`, which a precompiled Scope or Generic lacks
5003 scopeReadOf(
5004 node: Node,
5005 module: SourceModule
5006 ): [read: string, kind: StandInKind] | undefined {
5007 if (node.type !== "MemberExpression") return
5008 const name = memberNameOf(node)
5009 if (typeof name !== "string") return
5010 const inScope = name in scopeMembers
5011 const inGeneric = name in genericMembers
5012 if (!inScope && !inGeneric) return
5013 const objectKind = this.kindOf(node.object, module)
5014 if (
5015 !mayBeOtherArk(objectKind) ||
5016 (name in typeMemberKinds && (objectKind & kinds.type) !== 0) ||
5017 this.isArktypeImport(node.object, module)
5018 )
5019 return
5020 const isGeneric =
5021 (objectKind & kinds.returnsType) !== 0 &&
5022 (objectKind & kinds.returnsArk) === 0
5023 return [name, inScope && (!inGeneric || !isGeneric) ? "Scope" : "Generic"]
5024 }
5025
5026 // e.g. `getG()("string")` or `(flag ? G : G2)("string")`, instantiating what
5027 // may be a Generic outside a site, which no member read refuses; a callee

Callers 1

scopeReadsOfFunction · 0.80

Calls 4

kindOfMethod · 0.95
isArktypeImportMethod · 0.95
mayBeOtherArkFunction · 0.85
memberNameOfFunction · 0.70

Tested by

no test coverage detected