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

Method passedKindOf

ark/aot/graph.ts:2014–2051  ·  view source on GitHub ↗
(
		fn: FunctionNode,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

2012 }
2013
2014 private passedKindOf(
2015 fn: FunctionNode,
2016 module: SourceModule,
2017 kindOfKey: KindOfKey
2018 ): KindBits {
2019 let [operand, call] = operatorOf(fn)
2020 while (
2021 call?.type === "ArrayExpression" ||
2022 call?.type === "ObjectExpression" ||
2023 (call?.type === "Property" && call.value === operand)
2024 )
2025 [operand, call] = operatorOf(call)
2026 // e.g. `e` in `<input onFocus={e => e.target.select()} />`, which the
2027 // renderer calls with an event or element, unlike a component's prop
2028 if (
2029 call?.type === "JSXExpressionContainer" &&
2030 isIntrinsicElementAttribute(call.parent)
2031 )
2032 return kinds.data
2033 // e.g. an exported function or a method, called where the build can't see
2034 if (call?.type !== "CallExpression" || call.callee === operand)
2035 return opaque
2036 const callee = unwrapChain(call.callee)
2037 if (callee.type !== "MemberExpression") {
2038 return lostOf(
2039 this.transfer(callee, module, kindOfKey) &
2040 (kinds.returnsType | kinds.returnsArk)
2041 )
2042 }
2043 // a container method or `then` may pass what its receiver holds
2044 const name = memberNameOf(callee)
2045 return isContainerMethod(name) || name === "then" ?
2046 lostOf(
2047 this.transfer(callee.object, module, kindOfKey) &
2048 (kinds.unknown | kinds.holder)
2049 )
2050 : kinds.data
2051 }
2052
2053 // e.g. `Params` for `p` in `(p: Params) => p.or`, where `Params` is computed or `any`
2054 unreadAnnotationOf(node: Node, module: SourceModule): Node | undefined {

Callers 1

paramKindOfMethod · 0.95

Calls 7

transferMethod · 0.95
operatorOfFunction · 0.90
unwrapChainFunction · 0.90
lostOfFunction · 0.85
isContainerMethodFunction · 0.85
memberNameOfFunction · 0.70

Tested by

no test coverage detected