( name: string | undefined, binding: Binding, runtime: RuntimeModule )
| 417 | // arktype's export, as what it may hand a program of the errors class, or |
| 418 | // undefined for its default or namespace |
| 419 | private readArkImport( |
| 420 | name: string | undefined, |
| 421 | binding: Binding, |
| 422 | runtime: RuntimeModule |
| 423 | ): void { |
| 424 | if (name !== "type" && name !== "ArkErrors") { |
| 425 | this.used.add("errors") |
| 426 | // the class itself, or a default or namespace it's read off |
| 427 | if (name === undefined || name === "TraversalError") |
| 428 | this.used.add("thrown") |
| 429 | return |
| 430 | } |
| 431 | for (const { id } of binding.references) { |
| 432 | if (isDead(id, runtime)) continue |
| 433 | let [operand, parent] = operatorOf(id) |
| 434 | if (name === "type") { |
| 435 | if (parent?.type === "CallExpression" && parent.callee === operand) |
| 436 | continue |
| 437 | if ( |
| 438 | parent?.type !== "MemberExpression" || |
| 439 | parent.object !== operand || |
| 440 | isWriteTarget(parent) |
| 441 | ) { |
| 442 | this.used.add("errors") |
| 443 | continue |
| 444 | } |
| 445 | if (memberNameOf(parent) !== "errors") continue |
| 446 | ;[operand, parent] = operatorOf(parent) |
| 447 | } |
| 448 | if ( |
| 449 | parent?.type === "BinaryExpression" && |
| 450 | parent.operator === "instanceof" && |
| 451 | parent.right === operand |
| 452 | ) |
| 453 | this.errorsTests.add(operand) |
| 454 | else this.used.add("errors") |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | // a call's result, which holds errors unless it's past a test for them |
| 459 | private readResult(call: Node, runtime: RuntimeModule): void { |
no test coverage detected