# Language-Specific Simplification Examples Load this file on-demand when the target code uses a specific language. Teqo is TypeScript-only; Python is included for general reference. ## TypeScript / JavaScript ```typescript // SIMPLIFY: Unnecessary async wrapper // Before async function getUser(id: string): Promise { return await userService.findById(id); } // After function getUser(id: string): Promise { return userService.findById(id); } // SIMPLIFY: Manual array building → filter // Before const activeUsers: User[] = []; for (const user of users) { if (user.isActive) activeUsers.push(user); } // After const activeUsers = users.filter((u) => u.isActive); // SIMPLIFY: Verbose conditional assignment // Before let displayName: string; if (user.nickname) { displayName = user.nickname; } else { displayName = user.fullName; } // After const displayName = user.nickname || user.fullName; // SIMPLIFY: Redundant boolean return // Before function isValid(input: string): boolean { if (input.length > 0 && input.length < 100) return true; return false; } // After function isValid(input: string): boolean { return input.length > 0 && input.length < 100; } ``` ## Python ```python # SIMPLIFY: Verbose dictionary building # Before result = {} for item in items: result[item.id] = item.name # After result = {item.id: item.name for item in items} # SIMPLIFY: Nested conditionals with early return # Before def process(data): if data is not None: if data.is_valid(): if data.has_permission(): return do_work(data) else: raise PermissionError("No permission") else: raise ValueError("Invalid data") else: raise TypeError("Data is None") # After def process(data): if data is None: raise TypeError("Data is None") if not data.is_valid(): raise ValueError("Invalid data") if not data.has_permission(): raise PermissionError("No permission") return do_work(data) ``` ## React / JSX ```tsx // SIMPLIFY: Verbose conditional rendering // Before function UserBadge({ user }: Props) { if (user.isAdmin) { return Admin; } else { return User; } } // After function UserBadge({ user }: Props) { const variant = user.isAdmin ? 'admin' : 'default'; const label = user.isAdmin ? 'Admin' : 'User'; return {label}; } ```