ken-you-code
Version:
Connect your codebase to Kimi: Ultra-fast AI code analysis with Kimi-K2 model via MCP
46 lines (37 loc) • 986 B
text/typescript
// Complex TypeScript file for testing
interface User {
id: number;
name: string;
email?: string;
}
class UserManager {
private users: User[] = [];
addUser(user: any): void {
this.users.push(user);
}
getUserById(id: number): User | undefined {
return this.users.find((user) => user.id === id);
}
// Async method with proper error handling
async fetchUserData(userId: number): Promise<User> {
try {
const response = await fetch(`/api/users/${userId}`);
return await response.json();
} catch (error) {
throw new Error(`Failed to fetch user: ${error}`);
}
}
// Method with type issues
processUsers(callback: Function): any {
return this.users.map(callback);
}
}
// Function with missing return type
function calculateAge(birthYear) {
return new Date().getFullYear() - birthYear;
}
// Generic function
function identity<T>(value: T): T {
return value;
}
export { UserManager, User, calculateAge, identity };