The migration will follow a systematic bottom-up approach to minimize breaking changes and maintain a working codebase throughout the process.
Goal: Establish core type definitions and convert utility functions that have no dependencies.
Files to migrate first (3-35 lines each):
src/lib/utils.js(3 lines) - Core symbols and simple utilitiessrc/lib/icons.js(66 lines) - SVG icon templatessrc/grouped-list/index.js(1 line) - Simple barrel exportsrc/lib/settings/drivers/index.js(3 lines) - Driver exportssrc/lib/settings/index.js(3 lines) - Settings exports
Core type definitions to create:
// src/types/core.ts
export interface OmnitableItem {
[key: string]: unknown;
}
export interface ColumnConfig {
name: string;
title: string;
valuePath: string;
priority?: number;
width?: number;
minWidth?: number;
flex?: number;
disabled?: boolean;
// ... other properties
}
// src/types/column.ts - Column interface definitions
// src/types/events.ts - Custom event type definitions
// src/types/components.ts - Component prop interfacesGoal: Convert standalone utility functions and generic helpers.
Files to migrate (35-80 lines each):
src/lib/generic-sorter.js(35 lines) - Sorting algorithmssrc/lib/utils-data.js(42 lines) - Data manipulation utilitiessrc/lib/use-canvas-width.js(12 lines) - Canvas width hooksrc/lib/use-mini.js(30 lines) - Mini mode logicsrc/lib/polymer-haunted-render-mixin.js(18 lines) - Polymer integrationsrc/lib/save-as-csv-action.js(32 lines) - CSV export utilitysrc/lib/save-as-xlsx-action.js(25 lines) - XLSX export utility
Key benefits:
- Establish patterns for hook typing
- Create utility type definitions
- Build confidence with smaller, isolated files
Goal: Convert the settings system which is relatively self-contained.
Files to migrate (16-77 lines each):
src/lib/settings/drivers/context.js(16 lines)src/lib/settings/drivers/local.js(29 lines)src/lib/settings/drivers/remote.js(22 lines)src/lib/settings/normalize.js(77 lines)src/lib/settings/use-saved-settings.js(44 lines)src/lib/settings/use-settings.js(53 lines)
Dependencies: Phase 1 & 2 utilities
Goal: Convert core data processing logic and state management hooks.
Files to migrate (71-265 lines each):
src/lib/use-hash-state.js(71 lines) - URL state managementsrc/lib/use-sort-and-group-options.js(104 lines) - Sorting/grouping statesrc/lib/use-processed-items.js(265 lines) - Data processing pipelinesrc/grouped-list/use-weak-state.js(21 lines) - Weak state managementsrc/grouped-list/use-selected-items.js(141 lines) - Selection statesrc/grouped-list/use-collapsible-items.js(32 lines) - Collapsible state
Dependencies: Settings system, utilities
Goal: Convert column-specific utility files and mixins.
Files to migrate (112-211 lines each):
src/lib/utils-number.js(112 lines) - Number utilitiessrc/lib/utils-date.js(211 lines) - Date utilitiessrc/lib/utils-time.js(115 lines) - Time utilitiessrc/lib/utils-datetime.js(71 lines) - DateTime utilitiessrc/lib/utils-amount.js(147 lines) - Amount/currency utilitiessrc/lib/cosmoz-omnitable-date-input-mixin.js(183 lines) - Date input mixin
Key focus:
- Establish strong typing for data processing functions
- Create type-safe validation and conversion utilities
- Define interfaces for different data types (numbers, dates, amounts)
Goal: Convert layout computation and rendering logic.
Files to migrate (32-81 lines each):
src/lib/use-layout.js(32 lines) - Layout hookssrc/lib/layout.js(64 lines) - Layout calculationssrc/lib/compute-layout.js(72 lines) - Layout computationsrc/lib/use-fast-layout.js(73 lines) - Optimized layoutsrc/lib/use-resizable-columns.js(63 lines) - Resizable columnssrc/lib/render-header.js(51 lines) - Header renderingsrc/lib/render-footer.js(65 lines) - Footer renderingsrc/lib/render-list.js(81 lines) - List rendering
Dependencies: Core utilities, data processing
Goal: Convert range input components (most complex individual files).
Files to migrate (122-490 lines each):
src/lib/cosmoz-omnitable-range-input-mixin.js(490 lines) - Base range inputsrc/lib/cosmoz-omnitable-amount-range-input.js(358 lines) - Amount rangessrc/lib/cosmoz-omnitable-number-range-input.js(179 lines) - Number rangessrc/lib/cosmoz-omnitable-date-range-input.js(125 lines) - Date rangessrc/lib/cosmoz-omnitable-datetime-range-input.js(122 lines) - DateTime rangessrc/lib/cosmoz-omnitable-time-range-input.js(131 lines) - Time ranges
Key challenges:
- Complex mixin patterns
- Event handling and state management
- UI component integration
Goal: Convert individual column components.
Files to migrate (92-198 lines each):
src/cosmoz-omnitable-column-mixin.js(150 lines) - Base column mixinsrc/cosmoz-omnitable-column.js(100 lines) - Basic columnsrc/cosmoz-omnitable-column-boolean.js(159 lines) - Boolean columnsrc/cosmoz-omnitable-column-autocomplete.js(119 lines) - Autocomplete columnsrc/cosmoz-omnitable-column-list-mixin.js(198 lines) - List column basesrc/cosmoz-omnitable-column-list.js(92 lines) - List columnsrc/cosmoz-omnitable-column-list-horizontal.js(67 lines) - Horizontal listsrc/cosmoz-omnitable-column-list-data.js(133 lines) - Data list columnsrc/cosmoz-omnitable-column-number.js(157 lines) - Number columnsrc/cosmoz-omnitable-column-amount.js(166 lines) - Amount columnsrc/cosmoz-omnitable-column-date.js(137 lines) - Date columnsrc/cosmoz-omnitable-column-time.js(141 lines) - Time columnsrc/cosmoz-omnitable-column-datetime.js(150 lines) - DateTime column
Dependencies: Range inputs, column utilities, mixins
Goal: Convert core table components and main hooks.
Files to migrate (99-263 lines each):
src/lib/use-dom-columns.js(167 lines) - DOM column managementsrc/lib/use-omnitable.js(99 lines) - Main table hooksrc/lib/use-public-interface.js(108 lines) - Public APIsrc/lib/use-list.js(263 lines) - List managementsrc/grouped-list/utils.js(87 lines) - Grouped list utilitiessrc/grouped-list/use-cosmoz-grouped-list.js(115 lines) - Grouped list hook
Dependencies: All previous phases Components
Goal: Convert UI components and row renderers.
Files to migrate (12-78 lines each):
src/cosmoz-omnitable-item-expand.js(28 lines) - Item expand componentsrc/cosmoz-omnitable-item-expand-line.js(39 lines) - Expand linesrc/cosmoz-omnitable-item-row.js(38 lines) - Item rowsrc/cosmoz-omnitable-group-row.js(12 lines) - Group rowsrc/cosmoz-omnitable-header-row.js(78 lines) - Header rowsrc/grouped-list/cosmoz-grouped-list-row.js(41 lines) - Grouped list rowsrc/grouped-list/cosmoz-grouped-list.js(13 lines) - Grouped listsrc/ui-helpers/cosmoz-clear-button.js(69 lines) - Clear button
Goal: Convert main table component and styling.
Files to migrate (10-585 lines each):
src/cosmoz-omnitable-skeleton.js(70 lines) - Loading skeletonsrc/cosmoz-omnitable-columns.js(10 lines) - Columns componentsrc/cosmoz-omnitable-styles.js(585 lines) - Main stylessrc/lib/settings/style.css.js(260 lines) - Settings stylessrc/lib/settings/cosmoz-omnitable-settings.js(182 lines) - Settings componentsrc/cosmoz-omnitable.js(83 lines) - Main component
As we progress through phases, we'll gradually strengthen TypeScript settings:
Phase 1-3 (Permissive):
{
"strict": false,
"allowJs": true,
"checkJs": false,
"noImplicitAny": false
}Phase 4-7 (Moderate):
{
"strict": true,
"allowJs": true,
"noImplicitAny": true,
"strictNullChecks": true
}Phase 8+ (Strict):
{
"strict": true,
"allowJs": false,
"noImplicitAny": true,
"strictNullChecks": true,
"exactOptionalPropertyTypes": true
}-
Import/Export Patterns:
- Use explicit type imports:
import type { Type } from './types' - Maintain barrel exports for public APIs
- Use consistent naming conventions
- Use explicit type imports:
-
Type Definitions:
- Create interfaces for all component props
- Define union types for enums and constants
- Use generic types for reusable components
-
Event Handling:
- Type all custom events with proper detail types
- Use proper DOM event types
- Define event handler interfaces
-
Component Props:
- Use readonly for immutable props
- Define optional vs required properties clearly
- Use discriminated unions for variant props
- Unit Tests: Update tests as files are converted
- Integration Tests: Ensure backward compatibility
- Type Tests: Add type-only tests for complex types
- Build Verification: Continuous compilation checks
- Incremental Migration: Each phase can be merged independently
- Backward Compatibility: Maintain dual .js/.ts support during transition
- Rollback Strategy: Each phase can be reverted if issues arise
- Feature Flags: Use conditional compilation if needed
- ✅ All files compile without TypeScript errors
- ✅ All existing tests continue to pass
- ✅ Type coverage above 85%
- ✅ No runtime regressions
- ✅ Improved developer experience (better IDE support, autocomplete)
- ✅ Documentation improvements through typed interfaces
- Phase 1-3: 1-2 weeks (Foundation & utilities)
- Phase 4-6: 2-3 weeks (Core logic & rendering)
- Phase 7-8: 3-4 weeks (Complex components)
- Phase 9-11: 2-3 weeks (Main components & polish)
Total Estimated Duration: 8-12 weeks for complete migration
├── src/ # Source files (JavaScript → TypeScript)
│ ├── types/ # TypeScript type definitions
│ │ ├── core.ts # Core interfaces and types
│ │ ├── column.ts # Column-related types
│ │ ├── events.ts # Event type definitions
│ │ └── components.ts # Component prop interfaces
│ ├── cosmoz-omnitable*.ts # Main component files
│ ├── lib/ # Utility and helper modules
│ ├── grouped-list/ # Grouped list functionality
│ └── ui-helpers/ # UI helper components
├── dist/ # Compiled output (auto-generated)
│ ├── *.js # Compiled JavaScript
│ ├── *.d.ts # Type declarations
│ └── *.js.map # Source maps
├── test/ # Tests (updated to use src/ paths)
├── demo/ # Demo files (updated to use src/ paths)
└── tsconfig.json # TypeScript configuration
The current setup allows for gradual migration:
- Development: Import from
src/(JavaScript files, gradual TypeScript conversion) - Production: Import from
dist/(compiled JavaScript with type definitions) - Both paths supported: Package exports allow importing from either location
This enables teams to:
- Continue developing with existing JavaScript files
- Gradually convert files to TypeScript
- Always have a working build
- Maintain backward compatibility
├── src/ # Source files (JavaScript → TypeScript)
│ ├── cosmoz-omnitable*.js # Main component files
│ ├── lib/ # Utility and helper modules
│ ├── grouped-list/ # Grouped list functionality
│ └── ui-helpers/ # UI helper components
├── dist/ # Compiled output (auto-generated)
│ ├── *.js # Compiled JavaScript
│ ├── *.d.ts # Type declarations
│ └── *.js.map # Source maps
├── test/ # Tests (updated to use src/ paths)
├── demo/ # Demo files (updated to use src/ paths)
└── tsconfig.json # TypeScript configuration