TsCompilerDiagnostic
On this page

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 only string
fileNameread only string
lineread only number
characterread only number
categoryread only 'error' | 'warning' | 'message'
codeoptionalread only string
startread only number

UTF-16 offset where the diagnostic’s span begins.

lengthread only number

Length of the diagnostic’s span, in UTF-16 code units.

endLineread only number

One-based line of the position start + length.

endCharacterread only number

One-based character of the position start + length.

Source

src/compiler/ts/source-file.ts, line 121, at commit 26de7be8

Edit this page Report a problem