You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: replace 'any' types with proper TypeScript types (fixes#1265)
TYPE SAFETY FIX - Phase 1: Critical Paths
Issue: #1265
Problem:
Widespread use of 'any' type across codebase (30+ occurrences) causing:
- No IDE autocomplete or type checking
- Runtime errors not caught at compile time
- Refactoring breaks silently
- Difficult to trace data flow
- Production runtime errors
Phase 1 Changes (Critical Paths):
This commit addresses the most critical type safety issues in core
authentication and API packages.
New Type Definitions:
- packages/api/src/types.ts - Message, User, ActionData, UiInteractionData
- packages/auth/src/types.ts - CurrentUser, AuthToken
Fixed Files:
- packages/api/src/cloneArray.ts
• Use generic type <T extends Record<string, unknown>>
• Properly typed cloning function
- packages/api/src/EmbeddedChatApi.ts
• onMessageCallbacks: Message type instead of any
• onActionTriggeredCallbacks: ActionData instead of any
• onUiInteractionCallbacks: UiInteractionData instead of any
- packages/auth/src/RocketChatAuth.ts
• currentUser: CurrentUser | null instead of any
• authListeners: Properly typed callbacks
- packages/auth/src/Api.ts
• request() data parameter: unknown instead of any
• ApiError constructor: unknown[] instead of any[]
- packages/rc-app/lib/getCallbackContent.ts
• config: CallbackConfig interface instead of any
• error parameter: optional string type
Exported Types:
- packages/api/src/index.ts - Export all types
- packages/auth/src/index.ts - Export all types
Impact:
✅ Type safety in critical authentication paths
✅ IDE autocomplete for message callbacks
✅ Compile-time error detection
✅ Better refactoring support
✅ Clearer data flow
Next Phase:
- Remaining packages (24+ files)
- Additional interfaces for complex types
- Stricter tsconfig settings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments