[]previous and next page

Diagnostic

A located problem in a source module, carried by CompileError (and typed for CompileResult.diagnostics).

A located problem in a source module, carried by CompileError (and typed for CompileResult.diagnostics). Offsets count UTF-16 code units, like string indexes.

Import#

ts
import type { Diagnostic } from "@shadow-js/compiler";

Signature#

ts
interface Diagnostic {
  /** Stable identifier of the problem, such as `PARSE_ERROR` or `INVALID_HTML_NESTING`. */
  code: string;
  /** Human-readable explanation, without the position. */
  message: string;
  /**
   * `"error"` stops compilation. The compiler itself only produces errors; a plugin may also
   * report `"warning"` and `"info"` findings, which are collected in `CompileResult.diagnostics`.
   */
  severity: "error" | "warning" | "info";
  /** UTF-16 offset in the original source where the problem starts. */
  start: number;
  /** UTF-16 offset in the original source where the problem ends (exclusive). */
  end: number;
  /** 1-based line of `start`. */
  line: number;
  /** 0-based column of `start`, counted from the start of its line. */
  column: number;
  /** Name of the compiler plugin that caused the finding; absent for the compiler's own. */
  plugin?: string;
}

Members#

Name Type Description
code code: string Stable identifier of the problem, such as PARSE_ERROR or INVALID_HTML_NESTING.
message message: string Human-readable explanation, without the position.
severity severity: "error" | "warning" | "info" "error" stops compilation. The compiler itself only produces errors; a plugin may also report "warning" and "info" findings, which are collected in CompileResult.diagnostics.
start start: number UTF-16 offset in the original source where the problem starts.
end end: number UTF-16 offset in the original source where the problem ends (exclusive).
line line: number 1-based line of start.
column column: number 0-based column of start, counted from the start of its line.
plugin? plugin?: string Name of the compiler plugin that caused the finding; absent for the compiler's own.