# `Typsty.Diagnostic`
[🔗](https://github.com/akoutmos/typsty/blob/0.1.0/lib/typsty/diagnostic.ex#L1)

An error or warning reported by Typst.

- `:severity` - `:error` or `:warning`.
- `:message` - what the problem is.
- `:file` - the file the problem is in. For a problem in the template itself, it's the
  template's file (the module's `.ex` file for the `~TYPST` sigil, or its `.typ` file), or
  `nil` for a template rendered from a string. For a problem in a component (see
  `Typsty.Component`), it's the component's file, in the same way. For other files, it's
  their path in the project (`/styles.typ`), or `@namespace/name:version/path` for a file
  in a package.
- `:line` and `:column` - where the problem is, both starting at 1, or `nil` when it has
  no location. For the template itself and for components, they point into their file:
  the line of a `~TYPST` sigil in the module, for example.
- `:hints` - suggestions from Typst to fix the problem.
- `:trace` - for a problem in a function or a file called from elsewhere, the calls that
  led to it, as maps with the `:message`, `:file`, `:line` and `:column` keys.

# `t`

```elixir
@type t() :: %Typsty.Diagnostic{
  column: pos_integer() | nil,
  file: String.t() | nil,
  hints: [String.t()],
  line: pos_integer() | nil,
  message: String.t(),
  severity: :error | :warning,
  trace: [trace_point()]
}
```

# `trace_point`

```elixir
@type trace_point() :: %{
  message: String.t(),
  file: String.t() | nil,
  line: pos_integer() | nil,
  column: pos_integer() | nil
}
```

# `format`

```elixir
@spec format(t()) :: String.t()
```

Formats the diagnostic as a message, like `lib/invoice.ex:12:5: unknown variable: total`,
followed by its hints and trace.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
