Diagnostic
On this page

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 26de7be8.

Syntax

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

ruleIdread only string

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

severityread only 'error' | 'warning'

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

messageread only string

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

fnoptionalread only string

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

codeoptionalread only string

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

locoptionalread only SourceLoc

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

hintoptionalread only string

One-line suggestion for how to fix the problem.

Source

src/core/passes/lint/engine.ts, line 36, at commit 26de7be8

Edit this page Report a problem