-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Phase 8: Fix implicit any types - TypeScript error reduction #2711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
- Remove unused React imports from all icon components (26 files)
- Remove unused React imports from simple UI components: AgentHeader, LoadingPlaceholder, Splash, SplashPills, WelcomeGooseLogo
- Convert App.tsx from 'import React, { ... }' to 'import { ... }'
- Reduces TypeScript errors by ~30 (from 80+ unused React imports to 53)
- Conservative approach - only touched components that clearly don't use React directly
- No functionality changes, purely cleanup
- Fix unused parameters by prefixing with underscore (TypeScript convention): - ProviderSetupModal.tsx: _model: _, _endpoint: __ - OllamaBattleGame.tsx: requiredKeys: _ (with comprehensive fixes) - AddModelModal.tsx: _isValid: _, _validationErrors: __ - main.ts: Multiple unused event parameters → _event, version → _version - Fix OllamaBattleGame.tsx completely: - Remove unused React import - Fix Audio type from custom to HTMLAudioElement - Fix computed property with null check for configKey - Fix function type casting for choices array/function - Add comprehensive asset type declarations (PNG, MP3, etc.) - Reduces TypeScript errors by ~20 (from 381 to 361) - All changes use TypeScript conventions for intentionally unused parameters - No functionality changes, purely cleanup and type safety improvements
- Fix AlertBox.tsx: Add non-null assertions for alert.progress properties (safe because already guarded by alert.progress ? check) - Fix ConfigContext.tsx: Add optional chaining for API response data access - response.data?.config, configResponse.data?.config - extensionsResponse.data?.extensions with fallback to empty array - Fix App.tsx: Correct extractRemoteUrl return type to string | null (URLSearchParams.get() returns string | null, not string) - Fix SearchBar.tsx: Improve null checks for localSearchResults access - Better conditional logic to handle undefined count property - Bonus: Comprehensive asset type declarations in json.d.ts - Added PNG, JPG, GIF, SVG, MP3, MP4 module declarations - Fixes all asset import TypeScript errors - Reduces TypeScript errors by 11 (from 361 to 350) - Uses proper TypeScript patterns: optional chaining (?.) and non-null assertions (!) - All changes are conservative and preserve existing runtime behavior
- Fix App.tsx complex type issues:
- Add safe type assertions for initializeSystem parameters (provider as string, model as string)
Already null-checked with if (provider && model) so assertions are safe
- Fix all Electron IPC event handlers with 'as any' casts for type compatibility
Electron's .on() expects (...args: unknown[]) but we provide typed handlers
- Fix View type casting for viewFromUrl parameter
- Fix implicit any parameter types:
- ChatView.tsx: Add explicit ChatType for prevChat parameter in setChat callback
- GoosehintsModal.tsx: Add comprehensive prop types for all components:
* Modal: children: React.ReactNode
* ModalError: error: any
* ModalFileInfo: filePath: string; found: boolean
* ModalButtons: onSubmit/onCancel function types
* getGoosehintsFile: filePath: string parameter
- Reduces TypeScript errors by 19 (from 350 to 331)
- Higher complexity fixes while maintaining runtime safety
- Eliminates implicit any types with proper type annotations
- Total progress: 69+ errors eliminated across all phases (400+ → 331)
- Remove unused React imports from 51 files across the entire codebase
- Categories fixed:
* UI Components: Box, CustomRadio, Select, Send, Stop, VertDots, X, icons
* Main Components: GooseLogo, LoadingGoose, WelcomeView, GooseMessage, etc.
* Settings Components: Models, Providers, Extensions sections
* Modal Components: Various configuration and setup modals
* Utility Files: suspense-loader, toasts
- Changes made:
* 21 files: Removed simple 'import React from react'
* 24 files: Converted 'import React, { ... }' to 'import { ... }'
* 6 files: Removed various React import patterns
- Perfect prediction accuracy: eliminated exactly 51 errors (331 → 280)
- All files use new JSX transform, no functionality impact
- Total progress: 120+ errors eliminated across all phases (400+ → 280)
- Fix error handling with TypeScript best practices instead of using unknown/any: * LinkPreview.tsx: Use 'err instanceof Error ? err.message : fallback' pattern * ProviderGrid.tsx: Proper error type checking with meaningful fallback * SessionsView.tsx: Convert unknown error to string safely * ConfigureBuiltInExtensionModal.tsx: Type-safe error message extraction * ConfigureExtensionModal.tsx: Consistent error handling pattern - Applied TypeScript best practices: * No unknown or any types used - proper type guards instead * Consistent error checking pattern: 'err instanceof Error ? err.message : fallback' * Meaningful fallback values for non-Error objects * Improved type safety throughout error handling - Reduces TypeScript errors by 5 (from 280 to 275) - Better error handling with proper type safety - Maintainable code with consistent error patterns - Total progress: 125+ errors eliminated across all phases (400+ → 275)
- Fixed ChevronDown.tsx: Added proper className typing - Fixed Close.tsx: Added proper className typing - Fixed GooseLogo.tsx: Added interface and proper size typing with const assertion - Fixed ProviderGrid.tsx: Added proper provider parameter typing and object indexing - Fixed RecipeEditor.tsx: Added explicit string[] typing for exts variable - Fixed api_keys/utils.tsx: Added proper parameter typing for key functions - Fixed ManualExtensionModal.tsx: Added proper option parameter typing - Fixed AddModelInline.tsx: Added proper suggestion parameter typing - Fixed models/utils.tsx: Added proper function parameter typing - Fixed BaseProviderGrid.tsx: Added proper provider parameter and object indexing Reduced errors from 274 to 253 (21 errors eliminated) Systematic approach to implicit any types with proper TypeScript practices
salman1993
approved these changes
May 29, 2025
alexhancock
approved these changes
May 30, 2025
Collaborator
Author
|
closing in favor of #2741 |
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 8: Fix Implicit Any Types
Summary
Systematic fix of implicit any types throughout the TypeScript codebase, continuing the methodical error reduction strategy.
Changes Made
{ className?: string }typing{ className?: string }typingstring[]typing for exts variableTechnical Approach
keyof typeofpatternsanytypes introducedResults
Quality Assurance
Part of the ongoing systematic TypeScript error reduction effort.