Skip to content

Conversation

@zanesq
Copy link
Collaborator

@zanesq zanesq commented May 28, 2025

  • 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

- 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
@zanesq zanesq requested a review from alexhancock May 28, 2025 21:34
zanesq and others added 7 commits May 28, 2025 14:56
- 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
Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice tidying up - lets go

zanesq and others added 4 commits May 29, 2025 08:24
…hub.com:block/goose into fix/typescript-errors-phase1-unused-react-imports

* 'fix/typescript-errors-phase7-implicit-any-types' of github.com:block/goose:
  Cleanup Phase 8: Fix property access errors (TS2339) - TypeScript error reduction (#2713)
  Phase 7: Fix implicit any types
  Phase 6: Implement proper error handling without unknown/any types
  Phase 5: Remove remaining 51 unused React imports
  Phase 4: Fix complex type issues and IPC handler compatibility
  Phase 3: Fix null/undefined access with safe type assertions
  Phase 2: Fix unused variables and parameters
@zanesq zanesq merged commit 3d5d3ce into main May 29, 2025
7 checks passed
@zanesq zanesq deleted the fix/typescript-errors-phase1-unused-react-imports branch May 29, 2025 16:13
zanesq added a commit that referenced this pull request May 29, 2025
…ors-phase8-property-access

* 'main' of github.com:block/goose:
  Cleanup Phase 1: Remove unused React imports from safe components (#2702)
  feat: lancedb vector tool selection (#2654)
  feat: add claude 4 to vertex dropdown (#2697)
  ui-v2 cleanup (#2701)
zanesq added a commit that referenced this pull request May 29, 2025
….com:block/goose into fix/typescript-errors-phase9-type-assignment

* 'fix/typescript-errors-phase8-property-access' of github.com:block/goose:
  Cleanup Phase 1: Remove unused React imports from safe components (#2702)
  feat: lancedb vector tool selection (#2654)
  feat: add claude 4 to vertex dropdown (#2697)
  ui-v2 cleanup (#2701)
GitMurf pushed a commit to GitMurf/goose that referenced this pull request May 30, 2025
…ock#2702)

Co-authored-by: Michael Neale <michael.neale@gmail.com>
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
…ock#2702)

Co-authored-by: Michael Neale <michael.neale@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants