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

Method memberKindIn

ark/aot/graph.ts:3977–4033  ·  view source on GitHub ↗
(
		node: MemberExpression,
		object: Located,
		distributed: Set<Node>
	)

Source from the content-addressed store, hash-verified

3975 // member's own kind: e.g. a method's declared return, off whichever of
3976 // `globalForSteam.steam || new SteamClient(key)` holds the instance
3977 private memberKindIn(
3978 node: MemberExpression,
3979 object: Located,
3980 distributed: Set<Node>
3981 ): KindBits {
3982 const alternatives = this.alternativesOf(object, distributed)
3983 if (alternatives) {
3984 return alternatives.reduce(
3985 (kind, alternative) =>
3986 kind | this.memberKindIn(node, alternative, distributed),
3987 0
3988 )
3989 }
3990 const { module, kindOfKey } = object
3991 const name = memberNameOf(node)
3992 const alias = this.aliasKindOf(object.node, name, module, kindOfKey)
3993 if (alias !== undefined) return alias
3994 const literal = this.literalOf(object.node, module, kindOfKey)
3995 if (literal) {
3996 // e.g. `o.a` in `const o = { a: o.a }`
3997 if (this.resolving.has(node)) return 0
3998 this.resolving.add(node)
3999 try {
4000 const value = this.valueIn(literal, name)
4001 // e.g. `list.at` or `schemas[key]`, which may read what a holder holds
4002 return value ?
4003 this.transfer(value.node, value.module, value.kindOfKey)
4004 : kinds.data |
4005 (value === null ? 0 : this.heldKindOf(literal)) |
4006 unsureOf(this.transfer(object.node, module, kindOfKey))
4007 } finally {
4008 this.resolving.delete(node)
4009 }
4010 }
4011 if (typeof name === "string") {
4012 const cls = this.classOf(object.node, module, kindOfKey)
4013 if (cls) return kindOfKey(this.memberOf(cls.node, name), cls.module)
4014 }
4015 const passed = this.passedMemberKindOf(node, module, kindOfKey)
4016 if (passed !== undefined) return passed
4017 // the class of what a Type returns when validation fails
4018 if (
4019 name === "errors" &&
4020 this.arkExportNameOf(object.node, module) === "type"
4021 )
4022 return kinds.data
4023 if (
4024 typeof name === "string" &&
4025 name in typeParserKeywords &&
4026 this.arkExportNameOf(object.node, module) === "type"
4027 )
4028 return kinds.type
4029 return (
4030 memberKindOf(this.transfer(object.node, module, kindOfKey), name) |
4031 this.exposedKindOf(node, module, kindOfKey)
4032 )
4033 }
4034

Callers 1

transferMethod · 0.95

Calls 15

alternativesOfMethod · 0.95
aliasKindOfMethod · 0.95
literalOfMethod · 0.95
valueInMethod · 0.95
transferMethod · 0.95
heldKindOfMethod · 0.95
classOfMethod · 0.95
memberOfMethod · 0.95
passedMemberKindOfMethod · 0.95
arkExportNameOfMethod · 0.95
exposedKindOfMethod · 0.95
unsureOfFunction · 0.85

Tested by

no test coverage detected