/** * Typechecker - TypeScript type checking. * * Uses TypeScript's compiler API * Fetches TypeScript lib files (lib.dom.d.ts, etc.) from CDN and caches them. */ import type { ITypechecker, TypecheckOptions, TypecheckResult } from "../types"; import { type ICache } from "./persistor"; export interface TypecheckerOptions { /** * TypeScript lib names to include (e.g., "dom", "es2020"). * If not provided, uses sensible defaults: ["es2020", "dom", "dom.iterable"] */ libs?: string[]; /** * Base URL to fetch TypeScript lib files from. * Defaults to jsDelivr CDN. */ libsBaseUrl?: string; /** * Cache for TypeScript lib files. * If not provided, an internal in-memory cache is used (no sharing across instances). * * Key format: lib name (e.g., "dom", "es2020") */ cache?: ICache; } /** * Typechecker using TypeScript compiler API. * * Fetches TypeScript lib files from CDN and caches them. * Uses filesystem access for efficient type checking. * * @example * ```ts * const typechecker = new Typechecker(); * * const result = await typechecker.typecheck({ * fs: myFilesystem, * entryPoint: "/src/index.ts", * }); * * if (!result.success) { * console.log("Type errors:", result.diagnostics); * } * ``` */ export declare class Typechecker implements ITypechecker { private options; private cache; private initPromise; private initialized; constructor(options?: TypecheckerOptions); /** * Pre-fetch TypeScript lib files. * Called automatically on first typecheck() if not already done. */ initialize(): Promise; private fetchLibs; /** * Type check files in a filesystem. */ typecheck(options: TypecheckOptions): Promise; /** * Load all cached libs into a sync Map for the compiler host. * TypeScript's compiler host requires sync access to files. */ private loadLibsForCompiler; } /** * Create a typechecker instance. */ export declare function createTypechecker(options?: TypecheckerOptions): ITypechecker; //# sourceMappingURL=typechecker.d.ts.map