UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

63 lines (62 loc) 2.06 kB
import ts from "typescript"; /** * Utility class for resolving TypeScript types accurately */ export declare class TypeResolver { private typeChecker; constructor(typeChecker: ts.TypeChecker); /** * Resolves the return type of a function-like declaration * Handles both explicit and inferred types */ resolveFunctionReturnType(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): string; /** * Resolves parameter types for a function * Returns an array of type strings corresponding to each parameter */ resolveParameterTypes(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): string[]; /** * Checks if a function returns a Promise (is effectively async) */ isEffectivelyAsync(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean; /** * Resolves the type of a variable or property */ resolveVariableType(node: ts.VariableDeclaration | ts.PropertyDeclaration): string; /** * Checks if a type represents a generic type */ isGenericType(typeString: string): boolean; /** * Extracts generic type parameters from a type string */ extractGenericParameters(typeString: string): string[]; /** * Checks if a type is a union type */ isUnionType(typeString: string): boolean; /** * Checks if a type is an intersection type */ isIntersectionType(typeString: string): boolean; /** * Private helper to clean up type strings */ private cleanTypeString; /** * Private helper to check if a type string represents a Promise */ private isPromiseType; /** * Private helper to infer return type from a block statement */ private inferReturnTypeFromBlock; /** * Checks if a type is a primitive type */ isPrimitiveType(typeString: string): boolean; /** * Simplifies complex type strings for better readability */ simplifyTypeString(typeString: string): string; }