Skip to content

TypeScript strictness: eliminate any, @ts-ignore, and export prop types #675

@ravisuhag

Description

@ravisuhag

Summary

Several components have TypeScript safety issues: any types, @ts-ignore suppressions, missing type exports, unsafe type casting, and outdated type patterns. These reduce type safety for both maintainers and consumers.

Goal

Achieve strict TypeScript compliance across all components with zero any types, zero @ts-ignore comments, and full prop type exports.

Affected Components

Component Issue Details
Tooltip (#648) item 2 Unsafe index operation in getTransformForPlacementalign could be undefined
Toast (#647) items 1, 4 toast() uses wrong type (ToasterProps vs ToastOptions); empty interface extension
ThemeProvider (#646) item 1 Two @ts-ignore comments without explanation
Sidebar (#637) item 4 as?: ReactElement too permissive — should be React.ElementType
SidePanel (#636) item 2 SidePanelProps doesn't extend HTMLAttributes<HTMLAsideElement>
Radio (#630) item 3 RadioProps and RadioGroupProps not exported
List (#626) item 2 align prop declared in docs but missing from TypeScript interface
DataTable (#612) items 1, 3 as unknown as TData[] unsafe casting; column defs not memoized
Command (#609) item 1 export const Command: any — loses all type safety
Breadcrumb (#600) item 21 BreadcrumbProps extends HTMLDivElement but renders <nav>
Amount (#595) item 7 @ts-ignore on format() call
Accordion (#592) item 6 Deprecated ElementRef should be ComponentRef
Checkbox (#604) item 16 Deprecated ElementRef should be ComponentRef

Common Patterns to Fix

1. Replace any with proper types

// Before
export const Command: any = Object.assign(...)
// After
export const Command: CommandType = Object.assign(...)

2. Remove @ts-ignore with proper type handling

// Before
// @ts-ignore
format(finalBaseValue)
// After
format(Number(finalBaseValue))

3. Export prop types for consumer use

// Add to public API
export type { RadioProps, RadioGroupProps } from './radio';

4. Migrate ElementRefComponentRef

// Before (deprecated)
type Ref = React.ElementRef<typeof Primitive>;
// After
type Ref = React.ComponentRef<typeof Primitive>;

Acceptance Criteria

  • Zero any types in component source
  • Zero @ts-ignore / @ts-expect-error comments
  • All component prop interfaces exported from public API
  • ElementRef migrated to ComponentRef everywhere
  • No unsafe type casting (as unknown as)

Metadata

Metadata

Assignees

No one assigned

    Labels

    globalCross-cutting issue affecting multiple componentstriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions