( node: Node, module: SourceModule )
| 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, |
no test coverage detected