import * as ts from "typescript";
import { Result } from "@ts-std/monads";
import { NonEmpty } from "./utils";
export declare type SourceFile = Readonly<{
    source: string;
    filename?: string;
}>;
export declare type Span = Readonly<{
    file: SourceFile;
    start: number;
    end: number;
    line: number;
    column: number;
}>;
export declare function Span(file: SourceFile, start: number, text: string, line: number, column: number): Span;
export declare namespace Span {
    function fromTsNode(sourceFile: ts.SourceFile, { pos: start, end }: ts.TextRange): Span;
}
export declare type SpanError = Readonly<{
    region: Span | string;
    title: string;
    message: string;
    error: true;
}>;
export declare function SpanError(region: Span | string, title: string, paragraphs: string[]): Readonly<{
    region: string | Readonly<{
        file: Readonly<{
            source: string;
            filename?: string | undefined;
        }>;
        start: number;
        end: number;
        line: number;
        column: number;
    }>;
    title: string;
    message: string;
    error: true;
}>;
export declare type SpanWarning = Readonly<{
    region: Span | string;
    title: string;
    message: string;
    error: false;
}>;
export declare function SpanWarning(region: Span | string, title: string, paragraphs: string[]): SpanWarning;
declare type W = {
    warnings?: SpanWarning[];
};
export declare type SpanResult<T> = Result<{
    value: T;
} & W, {
    errors: NonEmpty<SpanError>;
} & W>;
export declare namespace SpanResult {
    function Ok<T>(value: T, warnings?: SpanWarning[]): SpanResult<T>;
    function TsNodeErr(sourceFile: ts.SourceFile, node: ts.TextRange, title: string, paragraphs: string[]): SpanResult<any>;
    function Err(fileName: string, title: string, paragraphs: string[]): SpanResult<any>;
    type UnSpan<R extends SpanResult<any>> = R extends SpanResult<infer T> ? Result<T, void> : never;
    function checkSuccess(errors: SpanError[], warnings: SpanWarning[]): [
        Result<void, NonEmpty<SpanError>>,
        SpanWarning[]
    ];
    class Context {
        readonly sourceFile: ts.SourceFile;
        protected errors: SpanError[];
        protected warnings: SpanWarning[];
        drop(): {
            errors: Readonly<{
                region: string | Readonly<{
                    file: Readonly<{
                        source: string;
                        filename?: string | undefined;
                    }>;
                    start: number;
                    end: number;
                    line: number;
                    column: number;
                }>;
                title: string;
                message: string;
                error: true;
            }>[];
            warnings: Readonly<{
                region: string | Readonly<{
                    file: Readonly<{
                        source: string;
                        filename?: string | undefined;
                    }>;
                    start: number;
                    end: number;
                    line: number;
                    column: number;
                }>;
                title: string;
                message: string;
                error: false;
            }>[];
        };
        constructor(sourceFile: ts.SourceFile);
        subsume<T>(result: SpanResult<T>): Result<T, void>;
        tsNodeWarn(node: ts.TextRange, title: string, paragraphs: string[]): void;
        warn(fileName: string, title: string, paragraphs: string[]): void;
        Err(node: ts.TextRange, title: string, ...paragraphs: string[]): Result<any, void>;
    }
}
export declare function formatDiagnostics(errors: SpanError[], warnings: SpanWarning[], lineWidth: number): string;
export declare function formatDiagnostic({ region, title, message, error }: SpanError | SpanWarning, lineWidth: number): string;
export {};
