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

Method aliasIn

ark/aot/graph.ts:4625–4666  ·  view source on GitHub ↗
(
		definition: Located,
		name: unknown
	)

Source from the content-addressed store, hash-verified

4623
4624 // null where the definition has no alias by the name, undefined if unknown
4625 private aliasIn(
4626 definition: Located,
4627 name: unknown
4628 ): { value: Located; isGeneric: boolean } | null | undefined {
4629 if (typeof name !== "string") return
4630 const properties = membersOf(definition.node)
4631 for (let i = properties.length - 1; i >= 0; i--) {
4632 const property = properties[i]
4633 if (property.type === "SpreadElement") {
4634 const { module, kindOfKey } = definition
4635 const spread =
4636 this.literalOf(property.argument, module, kindOfKey) ??
4637 this.moduleDefinitionOf(property.argument, module, kindOfKey)
4638 const alias =
4639 spread?.node.type === "ObjectExpression" ?
4640 this.aliasIn(spread, name)
4641 : undefined
4642 if (alias !== null) return alias
4643 continue
4644 }
4645 const key = "key" in property ? keyNameOf(property) : undefined
4646 if (
4647 key === undefined ||
4648 accessorKindOf(property) ||
4649 property.type !== "Property"
4650 )
4651 return
4652 const alias = String(key)
4653 const paramsStart = alias.indexOf("<")
4654 if (
4655 alias[0] === "#" ||
4656 (paramsStart === -1 ? alias : alias.slice(0, paramsStart)) !== name
4657 )
4658 continue
4659 if (property.method) return
4660 return {
4661 value: { ...definition, node: property.value },
4662 isGeneric: paramsStart !== -1
4663 }
4664 }
4665 return null
4666 }
4667
4668 private bindingLiteralOf(
4669 binding: Binding,

Callers 2

aliasKindOfMethod · 0.95
moduleDefinitionOfMethod · 0.95

Calls 6

literalOfMethod · 0.95
moduleDefinitionOfMethod · 0.95
accessorKindOfFunction · 0.85
StringInterface · 0.85
membersOfFunction · 0.70
keyNameOfFunction · 0.70

Tested by

no test coverage detected