import { PackageJson } from '../../project/package'; import { DetectionSource } from '..'; /** * Type system detection result. */ interface TypeSystemDetection { /** Type system identifier */ id: 'typescript' | 'flow' | 'jsdoc'; /** Human-readable name */ name: string; /** Detected version */ version?: string; /** Config file path */ configPath?: string; /** Strict mode enabled */ strictMode?: boolean; /** Detection confidence (0-100) */ confidence: number; /** Detection sources */ detectedFrom: DetectionSource[]; } /** * Type system detector interface. */ interface TypeSystemDetector { /** Type system identifier */ id: 'typescript' | 'flow' | 'jsdoc'; /** Human-readable name */ name: string; /** Check if type system is present */ detect(projectPath: string, packageJson?: PackageJson): TypeSystemDetection | null; } /** * Detect TypeScript in project. * * @param projectPath - Project directory path * @param packageJson - Optional pre-loaded package.json * @returns Detection result or null if not detected * * @example Detecting TypeScript * ```typescript * import { typescriptDetector } from '@hyperfrontend/project-scope' * * const result = typescriptDetector('./my-project') * if (result) { * console.log(`TypeScript ${result.version}`) * console.log(`Strict mode: ${result.strictMode ?? 'unknown'}`) * // => "TypeScript 5.3.0" * // => "Strict mode: true" * } * ``` */ declare function typescriptDetector(projectPath: string, packageJson?: PackageJson): TypeSystemDetection | null; /** * Detect Flow in project. * * @param projectPath - Project directory path * @param packageJson - Optional pre-loaded package.json * @returns Detection result or null if not detected * * @example Detecting Flow type system * ```typescript * import { flowDetector } from '@hyperfrontend/project-scope' * * const result = flowDetector('./my-project') * if (result) { * console.log(`Flow ${result.version} with config: ${result.configPath}`) * // => "Flow 0.232.0 with config: .flowconfig" * } * ``` */ declare function flowDetector(projectPath: string, packageJson?: PackageJson): TypeSystemDetection | null; /** * Detect JSDoc type annotations in project. * * @param projectPath - Project directory path * @param packageJson - Optional pre-loaded package.json * @returns Detection result or null if not detected * * @example Detecting JSDoc type annotations * ```typescript * import { jsdocDetector } from '@hyperfrontend/project-scope' * * const result = jsdocDetector('./my-project') * if (result) { * console.log('JSDoc types detected') * console.log('Sources:', result.detectedFrom.map(s => s.path ?? s.field)) * // => "Sources: ['jsconfig.json', 'src/utils.js (JSDoc annotations)']" * } * ``` */ declare function jsdocDetector(projectPath: string, packageJson?: PackageJson): TypeSystemDetection | null; /** All type system detectors */ declare const typeSystemDetectors: TypeSystemDetector[]; /** * Detect all type systems in project. * * @param projectPath - Project directory path * @param packageJson - Optional pre-loaded package.json * @returns Array of detected type systems, sorted by confidence * * @example Detecting all type systems * ```typescript * import { detectTypeSystems } from '@hyperfrontend/project-scope' * * const typeSystems = detectTypeSystems('./my-project') * // => [ * // { id: 'typescript', name: 'TypeScript', version: '5.3.0', strictMode: true, confidence: 95, ... }, * // { id: 'jsdoc', name: 'JSDoc', confidence: 40, ... } * // ] * * const primary = typeSystems[0]?.name ?? 'None' * console.log(`Primary type system: ${primary}`) * ``` */ declare function detectTypeSystems(projectPath: string, packageJson?: PackageJson): TypeSystemDetection[]; export { detectTypeSystems, flowDetector, jsdocDetector, typeSystemDetectors, typescriptDetector }; export type { TypeSystemDetection, TypeSystemDetector };