UNPKG

572 BPlain TextView Raw
1import ts from 'typescript';
2
3export class CompilerDiagnostic implements ts.Diagnostic {
4 public constructor(
5 private readonly node: ts.Node,
6 public readonly messageText: string,
7 public readonly code: number,
8 public readonly category: ts.DiagnosticCategory,
9 ) {}
10
11 public get file(): ts.SourceFile {
12 return this.node.getSourceFile();
13 }
14
15 public get start(): number {
16 return this.node.getStart();
17 }
18
19 public get length(): number {
20 return this.node.getWidth();
21 }
22
23 public get source(): string {
24 return this.node.getText();
25 }
26}