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

Method componentFunctionOfNode

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

Source from the content-addressed store, hash-verified

3253 }
3254
3255 private componentFunctionOfNode(
3256 node: Node,
3257 module: SourceModule
3258 ): [FunctionNode, SourceModule] | undefined {
3259 const unwrapped = namedFunctionOf(unwrapChain(node), module)
3260 if (isFunctionNode(unwrapped)) return [unwrapped, module]
3261 // e.g. `React.memo(Comp)` or `forwardRef((props, ref) => ...)`
3262 if (
3263 unwrapped.type === "CallExpression" &&
3264 unwrapped.arguments.length >= 1 &&
3265 unwrapped.arguments[0].type !== "SpreadElement"
3266 ) {
3267 const callee = unwrapChain(unwrapped.callee)
3268 const calleeName =
3269 callee.type === "Identifier" ? callee.name
3270 : callee.type === "MemberExpression" ? memberNameOf(callee)
3271 : undefined
3272 if (calleeName === "memo" || calleeName === "forwardRef") {
3273 const arg = unwrapChain(unwrapped.arguments[0])
3274 if (arg.type === "Identifier") {
3275 const binding = module.scopes.byId.get(arg)?.binding
3276 return binding && this.componentFunctionOfBinding(binding, module)
3277 }
3278 return this.componentFunctionOfNode(arg, module)
3279 }
3280 }
3281 }
3282
3283 private propTypesOf(
3284 type: TSType,

Callers 2

jsxComponentOfMethod · 0.95

Calls 6

unwrapChainFunction · 0.90
namedFunctionOfFunction · 0.85
isFunctionNodeFunction · 0.85
memberNameOfFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected