From 8db07465ed174674540b45d15649bb57b15de024 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Wed, 20 Aug 2025 09:26:48 +0000 Subject: [PATCH] fix(typescript): resolve ProfileService typing issues and eliminate any types - Replace unsafe (error as any).config patterns with proper type guards - Add hasConfigProperty() type guard for safe error property checking - Add getConfigProperty() method for type-safe config extraction - Eliminate @typescript-eslint/no-explicit-any violations Problem: ProfileService had unsafe type casting with (error as any).config that violated TypeScript type safety guidelines and caused linting errors. Solution: Implement proper type guards following established patterns: - hasConfigProperty() safely checks if error has config property - getConfigProperty() extracts config without type casting - Maintains exact same functionality while ensuring type safety Files changed: - src/services/ProfileService.ts: Replace any types with type guards Testing: Linting passes, type-check passes, functionality preserved. --- src/services/ProfileService.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/services/ProfileService.ts b/src/services/ProfileService.ts index 8f8abcdc..3ec64edd 100644 --- a/src/services/ProfileService.ts +++ b/src/services/ProfileService.ts @@ -261,13 +261,31 @@ export class ProfileService { if (this.isAxiosError(error)) { return error.config?.url; } - if (this.isApiError(error) && (error as any).config) { - const config = (error as any).config as { url?: string }; - return config.url; + if (this.isApiError(error) && this.hasConfigProperty(error)) { + const config = this.getConfigProperty(error); + return config?.url; } return undefined; } + /** + * Type guard to check if error has config property + */ + private hasConfigProperty( + error: unknown, + ): error is { config?: { url?: string } } { + return typeof error === "object" && error !== null && "config" in error; + } + + /** + * Safely extract config property from error + */ + private getConfigProperty(error: { + config?: { url?: string }; + }): { url?: string } | undefined { + return error.config; + } + /** * Type guard for AxiosError */