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

Method readsPrimitive

ark/aot/graph.ts:5611–5625  ·  view source on GitHub ↗
(
		member: MemberExpression,
		module: SourceModule
	)

Source from the content-addressed store, hash-verified

5609
5610 // e.g. `o.max` given `o = { max: 5 }`, or a member of an enum
5611 private readsPrimitive(
5612 member: MemberExpression,
5613 module: SourceModule
5614 ): boolean {
5615 const object = unwrapChain(member.object)
5616 let binding = module.scopes.byId.get(object)?.binding
5617 if (binding?.kind === "import") {
5618 const target = this.importOf(binding, module)
5619 binding = target.kind === "binding" ? target.binding : undefined
5620 }
5621 if (binding?.kind === "enum") return true
5622 const literal = this.literalOf(member.object, module, this.finalKindOfKey)
5623 const value = literal && this.valueIn(literal, memberNameOf(member))
5624 return !!value && isPrimitiveNode(unwrapExpression(value.node))
5625 }
5626
5627 // e.g. "Object.values" for `Object.values`
5628 private globalMemberOf(node: Node, module: SourceModule): string | undefined {

Callers 1

mayWriteFromMethod · 0.95

Calls 8

importOfMethod · 0.95
literalOfMethod · 0.95
valueInMethod · 0.95
unwrapChainFunction · 0.90
unwrapExpressionFunction · 0.90
isPrimitiveNodeFunction · 0.85
memberNameOfFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected