Skip to content

Tighten TypeScript types; remove 'any' usages in components/types #10

@sugan0tech

Description

@sugan0tech

Summary
Tighten TypeScript types by replacing any with precise types or safe generics to improve safety and readability.

Context
Several any usages weaken type safety:

  • src/layouts/DashboardLayout.tsx: NavItemProps.icon: any (should be IconType or ComponentType).
  • src/types/api.types.ts: WebSocketMessage.payload: any (should be a discriminated union or generic).
  • src/components/space/EditSpace.tsx: any in element lookups/mapping.
  • catch(error: any) patterns across components and API helpers.

Tasks

  • Replace any in NavItemProps.icon with IconType (from react-icons) or React.ComponentType.
  • Model WebSocketMessage as a discriminated union keyed by type, each with a typed payload.
  • Add proper types for element lookups in EditSpace (derive from Element/Space types).
  • Update catch clauses to use unknown and narrow to AxiosError/Error as appropriate.
  • Add minimal utility types where needed; avoid broad type assertions.

Acceptance Criteria

  • npm run lint passes with no-explicit-any satisfied for modified files.
  • No new type errors (tsc -b).
  • App flows (auth, dashboard, space edit) work as before.

Notes

  • Favor narrowing and generics over casting; keep changes scoped and incremental.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions