TsCompilerDiagnostic
Interface in Authoring
A source diagnostic produced while TypeShade analyzes or compiles TypeScript shader code.
import type { TsCompilerDiagnostic } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
interface TsCompilerDiagnostic { readonly message: string; readonly fileName: string; readonly line: number; readonly character: number; readonly category: 'error' | 'warning' | 'message'; readonly code?: string; readonly start: number; readonly length: number; readonly endLine: number; readonly endCharacter: number;}Description
line/character are one-based (external consumers, including language-service.ts, read
these) and mark the start of the offending node. start/length are UTF-16 offsets into the
file — node.getStart(sourceFile) and node.getEnd() - node.getStart(sourceFile) — so an
editor can underline the whole node rather than a single character; endLine/endCharacter
are the one-based position of start + length, in the same convention as line/character.
A diagnostic with no node behind it (a missing directive, a whole-module backend failure) uses
the file’s first statement as its span, or start: 0, length: 0 when the file has none — see
makeDiagnostic in diagnostic.ts.
Instance properties
messageread onlystringfileNameread onlystringlineread onlynumbercharacterread onlynumbercategoryread only'error' | 'warning' | 'message'codeoptionalread onlystringstartread onlynumberUTF-16 offset where the diagnostic’s span begins.
lengthread onlynumberLength of the diagnostic’s span, in UTF-16 code units.
endLineread onlynumberOne-based line of the position
start + length.endCharacterread onlynumberOne-based character of the position
start + length.
Source
src/compiler/ts/source-file.ts, line 121, at commit 26de7be8