🚧 Still under progress. Soon will be finished.

AnalyserDiagnostic

CLASS code

Description

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

Methods

  • format

    code

    Formats syntactic and semantic errors found during the analysis

    format(errors: Diagnostic[]): string

    Parameters

    errors Diagnostic[]

    Returns

    string:

    The diagnostics formatted

  • getAll

    code

    Used to retrieve all the errors the analyser has encountered

    getAll(): Diagnostic[]

    Returns

    Diagnostic[]:

    All the errors

  • isEmpty

    code

    Checks whether there are errors or not

    isEmpty(): boolean

    Returns

    boolean:

    True if there are no errors, otherwise false

  • flatten

    code

    A message may be a chain of multiple messages. This helps provide better context for an error. This function flattens the chain of messages

    flatten(diagnostic: Diagnostic): string

    Parameters

    diagnostic Diagnostic

    The error to flatten

    Returns

    string:

    The messages flattened

  • addOne

    code

    Adds a new diagnostic error

    addOne(node: Node | null | undefined, message: string | DiagnosticMessageChain): void

    Parameters

    node Node | null | undefined

    The node where the error was found

    message string | DiagnosticMessageChain

    The error message

    Returns

    void:
  • addMany

    code

    Adds multiple syntactic/semantic errors

    addMany(diagnostics: readonly Diagnostic[]): void

    Parameters

    diagnostics readonly Diagnostic[]

    An array of syntactic/semantic errors

    Returns

    void: