/**
 * The type check `run` makes before any call.
 *
 * The snippet, wrapped exactly as the sandbox wraps it (`WRAP_HEAD` /
 * `WRAP_TAIL` from `./sandbox.ts`), is type-checked against the declarations
 * of the client the host replays against (`NodeRun402`, from the SDK
 * declarations packaged beside this server in `sdk/dist`), with only the
 * bindings the sandbox installs declared: `r`, `console`, and the builtins.
 * No DOM and no Node types, so `fetch` and `process` stay undeclared, as they
 * are in the sandbox. `strict`, with `noImplicitAny` off: snippets are scratch
 * code, and an untyped helper parameter is not a mistake.
 *
 * The checker is TypeScript 7's API (`@typescript/native/unstable/async`): one
 * native child process per server, started on the first check and kept warm,
 * so a check costs milliseconds. Checks are serialized, because each one
 * rewrites the one snippet file the checker's project holds.
 *
 * The check refuses only what the sandbox cannot run as written. Two shapes
 * type-check badly yet run: an undeclared name read under `typeof` (the
 * sandbox's global-inventory probe), and a member reached through an
 * un-awaited `r` chain, which the replay resolves by awaiting every
 * intermediate. Both are exempt.
 *
 * A missing member on an SDK object (an instance of an SDK class, or `r`
 * itself) is reported with the replay's own `did_you_mean` search, run on
 * types instead of objects: the receiver's closest public members, else where
 * a member of that exact name lives (the receiver's namespaces, then the root,
 * then the root's namespaces). The checker never calls the SDK.
 *
 * When the checker cannot start or answer, the check is skipped and the
 * snippet runs unchecked: a checker fault must not take `run` away.
 */
import { UnknownMember } from "./sandbox-proxy.js";
/** Starting the checker (spawn, load the SDK's declarations) may take this long before the check is skipped. */
export declare const SNIPPET_CHECK_START_TIMEOUT_MS = 15000;
/** One check may take this long before it is skipped. */
export declare const SNIPPET_CHECK_TIMEOUT_MS = 5000;
export interface SnippetDiagnostic {
    /** 1-based, in the snippet's own coordinates. */
    line: number;
    column: number;
    /** TypeScript's code, e.g. `TS2551`. */
    code: string;
    message: string;
}
export type SnippetCheck = {
    status: "passed";
} | {
    status: "skipped";
    reason: string;
} | {
    status: "refused";
    /** Every error diagnostic, in source order. */
    diagnostics: SnippetDiagnostic[];
    /** Set when the first diagnostic is a member an SDK object does not have. */
    unknownMember?: UnknownMember;
};
interface TsType {
    readonly id: number;
    getSymbol(): Promise<TsSymbol | undefined>;
}
interface TsSymbol {
    readonly name: string;
    readonly flags: number;
}
interface TsDiagnostic {
    readonly pos: number;
    readonly code: number;
    readonly category: number;
    readonly text: string;
    readonly messageChain?: readonly TsDiagnostic[];
}
interface TsNode {
    readonly kind: number;
    readonly parent: TsNode;
    readonly expression?: TsNode;
    readonly name?: TsNode & {
        readonly text: string;
    };
    readonly text?: string;
}
interface TsChecker {
    getTypeAtLocation(node: TsNode): Promise<TsType | undefined>;
    getPropertiesOfType(type: TsType): Promise<readonly TsSymbol[]>;
    getTypeOfSymbol(symbols: readonly TsSymbol[]): Promise<(TsType | undefined)[]>;
    getTypeOfSymbol(symbol: TsSymbol): Promise<TsType | undefined>;
    getTypeArguments(type: TsType): Promise<readonly TsType[]>;
    resolveName(name: string, meaning: number, location?: {
        document: string;
        position: number;
    }): Promise<TsSymbol | undefined>;
}
interface TsProject {
    readonly program: {
        getSourceFile(file: string): Promise<unknown>;
        getSyntacticDiagnostics(file: string): Promise<readonly TsDiagnostic[]>;
        getSemanticDiagnostics(file: string): Promise<readonly TsDiagnostic[]>;
    };
    readonly checker: TsChecker;
}
interface TsApi {
    updateSnapshot(params: unknown): Promise<{
        getProject(configFileName: string): TsProject | undefined;
    }>;
    close(): Promise<void>;
}
interface TsAst {
    getTokenAtPosition(sourceFile: unknown, position: number): TsNode;
    isPropertyAccessExpression(node: TsNode): boolean;
    isCallExpression(node: TsNode): boolean;
    isElementAccessExpression(node: TsNode): boolean;
    isParenthesizedExpression(node: TsNode): boolean;
    isNonNullExpression(node: TsNode): boolean;
    isAwaitExpression(node: TsNode): boolean;
    isTypeOfExpression(node: TsNode): boolean;
    isIdentifier(node: TsNode): boolean;
}
interface Checker {
    api: TsApi;
    ast: TsAst;
    dir: string;
    file: string;
    config: string;
}
/** Starts the checker. Replaced in tests to exercise a checker that cannot start. */
type StartChecker = () => Promise<Checker>;
/** Stop the checker process. The next check starts a new one. */
export declare function closeSnippetChecker(): Promise<void>;
/** Tests: start the checker with `start` instead of TypeScript (null restores TypeScript). */
export declare function _setSnippetCheckerStart(start: StartChecker | null): Promise<void>;
/**
 * Type-check a snippet that already parses. Never throws: a checker that
 * cannot start or answer makes the check `skipped`.
 */
export declare function checkSnippet(code: string): Promise<SnippetCheck>;
export {};
//# sourceMappingURL=snippet-check.d.ts.map