@ts-ast-parser/core
Version:
Reflects a simplified version of the TypeScript AST for generating documentation
64 lines • 2.1 kB
TypeScript
import ts from 'typescript';
import type { AnalyserSystem } from './system/analyser-system.js';
/**
* Represents an error caused because of invalid arguments when
* calling the parse function
*/
export interface ArgumentError {
messageText: string;
}
export type AnalyserError = ArgumentError | ts.Diagnostic;
/**
* Internal class to enqueue any error during the analysis.
*
* There are two types of errors the analyser can throw:
*
* - **Config errors**: Errors because of invalid compiler options
* - **Syntactic/Semantic errors**: Errors thrown by the TypeScript compiler when parsing the code
*/
export declare class AnalyserDiagnostic {
private readonly _diagnostics;
private readonly _formatDiagnosticHost;
constructor(system: AnalyserSystem);
/**
* Formats syntactic and semantic errors found during the analysis
*
* @param errors
* @returns The diagnostics formatted
*/
format(errors: ts.Diagnostic[]): string;
/**
* Used to retrieve all the errors the analyser has encountered
*
* @returns All the errors
*/
getAll(): ts.Diagnostic[];
/**
* Checks whether there are errors or not
*
* @returns True if there are no errors, otherwise false
*/
isEmpty(): boolean;
/**
* A message may be a chain of multiple messages. This helps provide better
* context for an error. This function flattens the chain of messages
*
* @param diagnostic - The error to flatten
* @returns The messages flattened
*/
flatten(diagnostic: ts.Diagnostic): string;
/**
* Adds a new diagnostic error
*
* @param node - The node where the error was found
* @param message - The error message
*/
addOne(node: ts.Node | null | undefined, message: string | ts.DiagnosticMessageChain): void;
/**
* Adds multiple syntactic/semantic errors
*
* @param diagnostics - An array of syntactic/semantic errors
*/
addMany(diagnostics: readonly ts.Diagnostic[]): void;
}
//# sourceMappingURL=analyser-diagnostic.d.ts.map