---
title: "Diagnostic: interface in Diagnostics, TypeShade API"
description: "Diagnostic, an interface in Diagnostics. One problem reported by a lint rule or by validation."
url: https://typeshade.dev/api/diagnostic/
language: en
---

# `Diagnostic`

Interface in Diagnostics

One problem reported by a lint rule or by validation.

`import type { Diagnostic } from 'typeshade'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
interface Diagnostic {
  readonly ruleId: string;
  readonly severity: 'error' | 'warning';
  readonly message: string;
  readonly fn?: string;
  readonly code?: string;
  readonly loc?: SourceLoc;
  readonly hint?: string;
}
```

## Description

`ruleId`, `severity` and `message` are always present; the other fields are filled in when the reporting rule had the information.

`loc` points at the TypeScript that built the offending node. It is present only when source tracing (`setSourceTracing`) was on while the module was authored, so by default it is absent. `code` is an `SD####` code from the same catalogue thrown errors use (`CODES`), present on rules that map onto one. Tooling should branch on `code` or `ruleId`, since `message` is free text.

## Instance properties

**`ruleId` read only `string`**

Id of the rule that reported the problem, for example `'param-count'`.

**`severity` read only `'error' | 'warning'`**

`'error'` or `'warning'`. A rule configured `'off'` reports nothing, so no diagnostic carries that value.

**`message` read only `string`**

Human-readable description of the problem. Free text; branch on `code` or `ruleId` instead.

**`fn` optional read only `string`**

Name of the function the problem was found in, when the rule reported one. Module-level problems leave it unset.

**`code` optional read only `string`**

Stable diagnostic code (`SD####`) from `CODES`, for tooling and documentation links.

**`loc` optional read only `SourceLoc`**

Where in the authored TypeScript the offending node was built. Present only when source tracing (`setSourceTracing`) was on at the time.

**`hint` optional read only `string`**

One-line suggestion for how to fix the problem.

## Source

[`src/core/passes/lint/engine.ts`, line 36](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/lint/engine.ts#L36), at commit af54ddad5
