/** * TypeScript lens for type checking */ import { BaseLens } from '../base/BaseLens.js'; import { LensResult, ExecuteResult, LensOptions, Executor } from '../../types/index.js'; /** TypeScript/JavaScript source file extensions (exported for consumers) */ export declare const TS_SOURCE_EXTENSIONS: Set; /** * Options for TypeScriptLens with optional source file injection */ export interface TypeScriptLensOptions extends LensOptions { /** * Pre-discovered source files to use for file metrics. * When provided, skips filesystem discovery (making the lens browser-compatible). * Should be relative paths from the project root. */ sourceFiles?: string[]; } /** * TypeScript diagnostic category */ declare enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } /** * TypeScript error format from CLI output */ interface TypeScriptError { file: string; line: number; column: number; code: string; message: string; category?: DiagnosticCategory; } /** * Parsed TypeScript output including errors and analyzed files */ interface TypeScriptParsedOutput { errors: TypeScriptError[]; filesAnalyzed: number; /** List of all files analyzed by TypeScript (from --listFiles output) */ analyzedFilePaths: string[]; } /** * Lens for TypeScript type checking */ export declare class TypeScriptLens extends BaseLens { readonly name = "typescript"; readonly description = "TypeScript type checking"; readonly languages: string[]; readonly supportedTools: string[]; readonly requirements: import("../..").LensRequirements; private pathMapper?; private injectedSourceFiles?; constructor(executor?: Executor, options?: TypeScriptLensOptions); /** * Calculate quality score (0-100) from TypeScript results * * Scoring algorithm: * - Start at 100 * - Subtract penalty based on errors per file with errors * - Errors: 8 points per error per file * - Warnings: 2 points per warning per file * - Suggestions: 0.5 points per suggestion per file * - Floor at 0 * * Examples: * - 0 errors = 100 * - 1 error in 1 file = 92 (1 error/file × 8 = 8 points) * - 10 errors in 5 files = 84 (2 errors/file × 8 = 16 points) * - 50 errors in 1 file = 0 (50 errors/file × 8 = 400 points, floored) */ static calculateQualityScore(result: LensResult): number; /** * Parse TypeScript compiler output * * Note: When --listFiles is used, stdout contains the list of analyzed files * and stderr contains the error messages */ parse(output: ExecuteResult): TypeScriptParsedOutput; /** * Format TypeScript errors to standard format */ format(parsed: TypeScriptParsedOutput): LensResult; /** * Map TypeScript diagnostic category to standard severity */ private mapTSSeverity; /** * Categorize TypeScript error codes */ private categorizeError; /** * Get or create path mapper */ private getPathMapper; /** * Get all source files for file metrics. * Returns injected source files if provided, otherwise returns empty array. * Used as fallback when --listFiles output is not available. * * To provide source files, pass them via the `sourceFiles` option when * constructing the lens. This makes the lens browser-compatible by avoiding * direct filesystem access. * * @example * ```typescript * // With @principal-ai/codebase-composition * const tree = await filesystemService.buildFileSystemTreeFromPath(projectPath); * const sourceFiles = tree.allFiles * .filter(f => TS_SOURCE_EXTENSIONS.has(f.extension)) * .map(f => f.relativePath); * * const lens = new TypeScriptLens(executor, { sourceFiles }); * ``` * @returns Array of relative file paths */ private findAllSourceFiles; /** * Override execute to ensure proper flags */ execute(): Promise; } export {}; //# sourceMappingURL=TypeScriptLens.d.ts.map