Phase 12 and 13: Fix unknown error handling (TS18046) - TypeScript error reduction#2725
Merged
zanesq merged 3 commits intofix/typescript-errors-phase11-implicit-any-parametersfrom May 30, 2025
Conversation
Complete elimination of unknown error type errors: - Fixed ManualExtensionModal.tsx: Added proper error instanceof Error checks for toast error handling - Fixed models/utils.tsx: Added error type guard for model switching error messages - Fixed ConfigureProvidersGrid.tsx: Added proper error handling for provider configuration operations - Fixed agent-api.ts: Added comprehensive error type checking for extension API calls - Fixed extensions.tsx: Added error instanceof Error checks for extension add/remove operations - Fixed main.ts: Added proper error type guards for file system operations and error code checking Technical approach: - Used 'error instanceof Error' pattern for proper Error object detection - Added 'typeof error === object && code in error' for Node.js error codes - Converted unknown errors to strings with String(error) fallback - Maintained error message extraction while ensuring type safety Reduced errors from 174 to 157 (17 errors eliminated) Eliminated ALL TS18046 errors (15 unknown error type errors eliminated) All linting checks pass with zero warnings
…ction - Fix ProviderGrid.tsx undefined provider name with fallback - Fix bundled-extensions.ts optional properties with null coalescing - Fix ConfigureApproveMode.tsx string|null assignments with fallbacks - Fix SessionSharingSection.tsx onChange callback type - Fix Schedule Modals React Select callback type mismatches - Fix ManualExtensionModal.tsx Select onChange callback type - Fix AddModelInline.tsx Select onChange callback type - Fix extension-manager.ts shouldRetry return type and Error conversion - Fix ExtensionInfoFields.tsx Select onChange callback type Results: 157→146 total errors (-11), 40→30 TS2322 errors (-10) All lint checks pass with zero warnings
777c0b9
into
fix/typescript-errors-phase11-implicit-any-parameters
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 12: Fix Unknown Error Handling (TS18046)
Summary
Complete elimination of unknown error type errors throughout the TypeScript codebase, targeting TS18046 "Error is of type 'unknown'" errors through proper error type guards and handling patterns.
Changes Made
error instanceof Errorchecks for toast error handlingerror instanceof Errorchecks for extension add/remove operations (2 locations)Technical Approach
error instanceof Errorpattern for proper Error object detectiontypeof error === 'object' && 'code' in errorfor file system error codesString(error)for safe conversion of unknown error typesResults
Quality Assurance
anytypes introducedError Handling Patterns Implemented
error instanceof Error ? error.message : String(error)error && typeof error === 'object' && 'code' in errorOverall Progress
Impact
This phase represents another significant milestone by completely eliminating a second entire category of TypeScript errors. The systematic approach of implementing proper error type guards and handling patterns has proven highly effective for improving code reliability and type safety.
Part of the ongoing systematic TypeScript error reduction effort with full linting compliance.