# seniority/explain

> Every export of seniority/explain, with its signature and doc comment: explain, explanation, renderExplanation, plus 1 type.

Source: https://seniority.interlace.tools/docs/api/explain

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->

```ts
import { explain, explanation, renderExplanation } from 'seniority/explain';
```

## Functions

### explain

The rendered form: what `--explain` prints.

```ts
function explain(name: string, resolution: Resolution): string;
```

| Parameter | Type |
| :-- | :-- |
| `name` | `string` |
| `resolution` | `Resolution` |

**Returns** `string`

### explanation

The record. Everything else in this file renders it.

```ts
function explanation(key: string, resolution: ExplainedResolution): Explanation;
```

| Parameter | Type |
| :-- | :-- |
| `key` | `string` |
| `resolution` | `ExplainedResolution` |

**Returns** `Explanation`

### renderExplanation

The human rendering — what `explain()` returns and a terminal prints.

```ts
function renderExplanation(e: Explanation): string;
```

| Parameter | Type |
| :-- | :-- |
| `e` | `Explanation` |

**Returns** `string`

## Interfaces

### Explanation

```ts
interface Explanation {
    /** The option asked about. */
    key: string;
    /** False when the command declares no such option — different from "declared and unset". */
    declared: boolean;
    /** The resolved value, or `undefined` when no source set one. */
    value: unknown;
    /** The candidate that won, or `undefined` when none did. */
    winner?: ExplainedCandidate;
    /** Every candidate, in `ORDER`. The truth table for this one option. */
    candidates: ExplainedCandidate[];
    /** Candidates that set a value and were outranked. */
    lost: ExplainedCandidate[];
    /**
     * Candidates that were consulted and had nothing. Kept apart from `lost` because
     * "the config file says `lib` and the flag beat it" and "there is no config file" are
     * different answers, and `--explain` exists to tell them apart.
     */
    unset: ExplainedCandidate[];
}
```
