diff_method_signatures – Method Signature Comparison
Compare method signatures between files to identify parameter mismatches and compatibility issues with detailed fix recommendations
Perfect For
API Compatibility Verification
Ensure method signatures match between API definitions and client implementations before deployment.
Refactoring Safety Checks
Verify that signature changes don’t break existing code by analyzing all call sites and implementations.
Version Migration Analysis
Compare method signatures between different API versions to plan backward compatibility strategies.
Interface Implementation Verification
Ensure that concrete classes properly implement interface methods with correct signatures.
Library Integration Debugging
Diagnose method signature mismatches when integrating third-party libraries or updating dependencies.
Quick Start
houtini-lm:diff_method_signatures with:
- callingFile: "C:/project/src/UserController.ts"
- methodName: "createUser"
- calledClass: "UserService"
- projectPath: "C:/project"
Multi-file signature comparison:
houtini-lm:diff_method_signatures with:
- files: ["C:/api/v1/users.ts", "C:/api/v2/users.ts"]
- methodName: "getUserById"
- analysisType: "comprehensive"
Signature Analysis Output
Method Signature Comparison
- Parameter Type Analysis: Detailed comparison of parameter types with TypeScript compatibility assessment
- Return Type Verification: Return type compatibility analysis including Promise wrapping and generic type parameters
- Optional Parameter Handling: Analysis of optional parameter placement and default value compatibility
Call-Site Analysis
- Usage Pattern Detection: How methods are actually called throughout the codebase
- Argument Mapping: Analysis of how arguments are passed and potential mismatches
- Breaking Change Impact: Identification of call sites that would break with signature changes
Compatibility Assessment
- Forward Compatibility: Whether newer signatures accept calls made to older signatures
- Backward Compatibility: Whether older signatures still work with newer implementations
- Migration Strategy: Step-by-step approach for safely updating signatures
Signature Analysis Example
API Evolution Example
// Original API (v1)
function createUser(name: string, email: string): Promise {
return userService.create({ name, email });
}
// Updated API (v2)
function createUser(
userData: CreateUserRequest,
options?: CreateUserOptions
): Promise> {
return userService.create(userData, options);
}
// Client code
const user = await createUser("John", "john@example.com"); // Breaking!
Analysis Results
- Breaking Change Detected: Parameter structure completely changed from individual parameters to object
- Return Type Change: Promise<User> became Promise<ApiResponse<User>>
- Affected Call Sites: 15 locations in codebase need updating
- Migration Strategy: Implement overloaded signatures for backward compatibility
Recommended Fix
// Backward-compatible implementation
function createUser(name: string, email: string): Promise;
function createUser(
userData: CreateUserRequest,
options?: CreateUserOptions
): Promise>;
function createUser(
nameOrUserData: string | CreateUserRequest,
emailOrOptions?: string | CreateUserOptions
): Promise> {
// Implementation handles both signatures
}
Parameters
Parameter | Type | Description | Example |
---|---|---|---|
callingFile | string | File containing method calls | “C:/src/UserController.ts” |
files | array | Multiple files to compare | [“api-v1.ts”, “api-v2.ts”] |
methodName | string | Specific method to analyze | “createUser” |
calledClass | string | Class containing the method | “UserService” |
projectPath | string | Project root for comprehensive analysis | “C:/project” |
analysisType | enum | Focus area for analysis | “signature” | “compatibility” | “comprehensive” |
Analysis Type Configuration
- signature – Focus on method signature differences and parameter matching
- compatibility – Analyze backward and forward compatibility implications
- comprehensive – Complete analysis including call-site impact and migration planning
Advanced Configuration
API Versioning Analysis: Compare signatures across different API versions to plan migration strategies.
// Version compatibility analysis
houtini-lm:diff_method_signatures with:
- files: [
"C:/api/v1/UserService.ts",
"C:/api/v2/UserService.ts",
"C:/api/v3/UserService.ts"
]
- methodName: "updateUser"
- analysisType: "comprehensive"
// Interface implementation verification
houtini-lm:diff_method_signatures with:
- files: ["C:/interfaces/IUserRepository.ts", "C:/impl/UserRepository.ts"]
- analysisType: "compatibility"
Refactoring Safety Workflow:
- Run diff_method_signatures before signature changes
- Identify all affected call sites and implementations
- Plan migration strategy with backward compatibility
- Implement signature changes with overloads if needed
- Use generate_unit_tests to verify compatibility
Pro Tips
TypeScript Advantage: TypeScript projects benefit from enhanced type analysis including generic type parameter compatibility and union type handling.
Gradual Migration: Use method overloading to maintain backward compatibility while transitioning to new signatures.
Documentation Generation: Use signature analysis results to automatically generate API migration documentation.
Related Functions
- compare_integration – Cross-system integration compatibility analysis
- trace_execution_path – Follow method calls through execution flow
- convert_to_typescript – Add type safety to enable better signature analysis
- generate_unit_tests – Create tests to verify signature compatibility