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 onlystringId 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 onlystringHuman-readable description of the problem. Free text; branch on
codeorruleIdinstead.fnoptionalread onlystringName of the function the problem was found in, when the rule reported one. Module-level problems leave it unset.
codeoptionalread onlystringStable diagnostic code (
SD####) fromCODES, for tooling and documentation links.locoptionalread onlySourceLocWhere in the authored TypeScript the offending node was built. Present only when source tracing (
setSourceTracing) was on at the time.hintoptionalread onlystringOne-line suggestion for how to fix the problem.
Source
src/core/passes/lint/engine.ts, line 36, at commit 26de7be8