( binding: Binding, module: SourceModule, ctx: ThisReadsContext, seen: Set<Binding> )
| 2314 | }) |
| 2315 | |
| 2316 | const isForwardingParam = ( |
| 2317 | binding: Binding, |
| 2318 | module: SourceModule, |
| 2319 | ctx: ThisReadsContext, |
| 2320 | seen: Set<Binding> |
| 2321 | ): boolean => { |
| 2322 | const fn = binding.declaration |
| 2323 | if (!isFunctionNode(fn)) return false |
| 2324 | const params = runtimeParamsOf(fn) |
| 2325 | const paramIndex = params.findIndex( |
| 2326 | param => |
| 2327 | param === binding.id || |
| 2328 | (param.type === "AssignmentPattern" && param.left === binding.id) |
| 2329 | ) |
| 2330 | if (paramIndex === -1) return false |
| 2331 | const paramNode = params[paramIndex] |
| 2332 | const defaultValue = |
| 2333 | paramNode.type === "AssignmentPattern" ? paramNode.right : undefined |
| 2334 | if (defaultValue && !isForwardingCallee(defaultValue, module, ctx, seen)) |
| 2335 | return false |
| 2336 | const calls = directCallsOfFunction(fn, module, ctx) |
| 2337 | if (!calls) return false |
| 2338 | return calls.every(({ call, module: callModule }) => { |
| 2339 | if ( |
| 2340 | call.arguments |
| 2341 | .slice(0, paramIndex + 1) |
| 2342 | .some(arg => arg.type === "SpreadElement") |
| 2343 | ) |
| 2344 | return false |
| 2345 | const arg = call.arguments[paramIndex] |
| 2346 | // omitted argument with no default yields undefined, which throws on .apply/.call |
| 2347 | if (!arg) return true |
| 2348 | return isForwardingCallee(arg, callModule, ctx, seen) |
| 2349 | }) |
| 2350 | } |
| 2351 | |
| 2352 | const directCallsOfFunction = ( |
| 2353 | fn: Node, |
no test coverage detected