( module: SourceModule, call: CallExpression )
| 7626 | |
| 7627 | // errors and mutatesInput configure() sets, reported once at the call |
| 7628 | private checkConfiguredOptions( |
| 7629 | module: SourceModule, |
| 7630 | call: CallExpression |
| 7631 | ): Diagnostic[] { |
| 7632 | const result: Diagnostic[] = [] |
| 7633 | const built = { |
| 7634 | errors: this.errors ?? "all", |
| 7635 | mutatesInput: this.mutatesInput ?? false |
| 7636 | } |
| 7637 | const imported = this.importClosureOf(module.id).flatMap(id => { |
| 7638 | const reached = this.graph.moduleOf(id) |
| 7639 | return reached instanceof SourceModule ? |
| 7640 | reached.program.body.flatMap(statement => |
| 7641 | statement.type === "ImportDeclaration" ? |
| 7642 | [statement.source.value] |
| 7643 | : [] |
| 7644 | ) |
| 7645 | : [] |
| 7646 | }) |
| 7647 | for (const option of ["errors", "mutatesInput"] as const) { |
| 7648 | const configured = $ark.config[option] |
| 7649 | if (configured === undefined) continue |
| 7650 | if (configured !== built[option]) { |
| 7651 | result.push( |
| 7652 | this.diagnostic( |
| 7653 | module, |
| 7654 | call, |
| 7655 | "R3", |
| 7656 | option === "errors" ? |
| 7657 | writeErrorsMismatchMessage(configured as never, built.errors) |
| 7658 | : writeMutatesInputMismatchMessage( |
| 7659 | configured as never, |
| 7660 | built.mutatesInput |
| 7661 | ), |
| 7662 | [], |
| 7663 | writeConfiguredOptionHint(option, printable(configured)) |
| 7664 | ) |
| 7665 | ) |
| 7666 | } |
| 7667 | if ( |
| 7668 | configured !== "all" && |
| 7669 | configured !== false && |
| 7670 | !imported.includes(`arktype/${option}`) |
| 7671 | ) { |
| 7672 | result.push( |
| 7673 | this.diagnostic( |
| 7674 | module, |
| 7675 | call, |
| 7676 | "R3", |
| 7677 | writeMissingImportMessage(option, printable(configured)), |
| 7678 | [], |
| 7679 | `Import "arktype/${option}" in the config module, as arktype throws creating a Type without it.` |
| 7680 | ) |
| 7681 | ) |
| 7682 | } |
| 7683 | } |
| 7684 | return result |
| 7685 | } |
no test coverage detected