/** * Agentic QE v3 - TypeScript AST Parser * Wrapper around TypeScript Compiler API for code analysis */ import * as ts from 'typescript'; /** * Information about a function parameter */ export interface ParameterInfo { name: string; type: string | undefined; isOptional: boolean; isRest: boolean; defaultValue: string | undefined; } /** * Information about a function (declaration or arrow function) */ export interface FunctionInfo { name: string; parameters: ParameterInfo[]; returnType: string | undefined; startLine: number; endLine: number; isAsync: boolean; isExported: boolean; isGenerator: boolean; typeParameters: string[]; } /** * Information about a class property */ export interface PropertyInfo { name: string; type: string | undefined; isStatic: boolean; isReadonly: boolean; visibility: 'public' | 'private' | 'protected'; hasInitializer: boolean; } /** * Information about a class method */ export interface MethodInfo { name: string; parameters: ParameterInfo[]; returnType: string | undefined; isAsync: boolean; isStatic: boolean; isAbstract: boolean; visibility: 'public' | 'private' | 'protected'; startLine: number; endLine: number; } /** * Information about a class */ export interface ClassInfo { name: string; methods: MethodInfo[]; properties: PropertyInfo[]; extends: string | undefined; implements: string[]; isAbstract: boolean; isExported: boolean; startLine: number; endLine: number; typeParameters: string[]; } /** * Information about named imports */ export interface NamedImportInfo { name: string; alias: string | undefined; } /** * Information about an import statement */ export interface ImportInfo { module: string; namedImports: NamedImportInfo[]; defaultImport: string | undefined; namespaceImport: string | undefined; isTypeOnly: boolean; } /** * Information about an export */ export interface ExportInfo { name: string; type: 'function' | 'class' | 'variable' | 'interface' | 'type' | 'enum' | 'namespace' | 'unknown'; isDefault: boolean; isReexport: boolean; sourceModule: string | undefined; } /** * Information about an interface property */ export interface InterfacePropertyInfo { name: string; type: string | undefined; isOptional: boolean; isReadonly: boolean; } /** * Information about an interface method */ export interface InterfaceMethodInfo { name: string; parameters: ParameterInfo[]; returnType: string | undefined; isOptional: boolean; } /** * Information about an interface */ export interface InterfaceInfo { name: string; properties: InterfacePropertyInfo[]; methods: InterfaceMethodInfo[]; extends: string[]; isExported: boolean; startLine: number; endLine: number; typeParameters: string[]; } /** * Visibility modifier type */ export type Visibility = 'public' | 'private' | 'protected' | 'internal'; /** * Entity type for parsed code elements */ export type ParsedEntityType = 'function' | 'class' | 'interface' | 'type' | 'variable' | 'enum' | 'module'; /** * Parsed entity representing a code element */ export interface ParsedEntity { name: string; type: ParsedEntityType; line: number; endLine?: number; visibility: Visibility; isAsync: boolean; isExported: boolean; parameters?: ParameterInfo[]; returnType?: string; extends?: string; implements?: string[]; } /** * TypeScript AST Parser * Provides methods to parse TypeScript source code and extract structural information */ export declare class TypeScriptParser { /** * Parse a TypeScript file and return the AST SourceFile */ parseFile(filePath: string, content: string): ts.SourceFile; /** * Extract all functions from the AST */ extractFunctions(ast: ts.SourceFile): FunctionInfo[]; /** * Extract all classes from the AST */ extractClasses(ast: ts.SourceFile): ClassInfo[]; /** * Extract all imports from the AST */ extractImports(ast: ts.SourceFile): ImportInfo[]; /** * Extract all exports from the AST */ extractExports(ast: ts.SourceFile): ExportInfo[]; /** * Extract all interfaces from the AST */ extractInterfaces(ast: ts.SourceFile): InterfaceInfo[]; /** * Extract all entities (functions, classes, interfaces, etc.) from source code * This is a convenience method that combines all extraction methods */ extractEntities(content: string, filePath: string): ParsedEntity[]; private getScriptKind; private extractFunctionDeclaration; private extractArrowFunctions; private extractClassDeclaration; private extractMethodDeclaration; private extractConstructor; private extractParameterProperties; private isParameterProperty; private extractPropertyDeclaration; private extractImportDeclaration; private extractExportDeclaration; private extractInterfaceDeclaration; private extractParameters; private extractTypeParameters; private getPropertyName; private getExportAssignmentName; private hasExportModifier; private hasDefaultModifier; private hasAsyncModifier; private hasStaticModifier; private hasAbstractModifier; private hasReadonlyModifier; private getVisibility; } export declare const typescriptParser: TypeScriptParser; //# sourceMappingURL=typescript-parser.d.ts.map