fix: replace 'any' types with proper TypeScript types (fixes #1265)#1269
Open
Harshit2405-2004 wants to merge 1 commit intoRocketChat:developfrom
Open
fix: replace 'any' types with proper TypeScript types (fixes #1265)#1269Harshit2405-2004 wants to merge 1 commit intoRocketChat:developfrom
Harshit2405-2004 wants to merge 1 commit intoRocketChat:developfrom
Conversation
…at#1265) TYPE SAFETY FIX - Phase 1: Critical Paths Issue: RocketChat#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TYPE SAFETY FIX - Phase 1: Critical Paths
Issue: #1265
Problem:
Widespread use of 'any' type across codebase (30+ occurrences) causing:
Phase 1 Changes (Critical Paths):
This commit addresses the most critical type safety issues in core authentication and API packages.
New Type Definitions:
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:
Impact:
✅ Type safety in critical authentication paths
✅ IDE autocomplete for message callbacks
✅ Compile-time error detection
✅ Better refactoring support
✅ Clearer data flow
Next Phase:
Brief Title
Acceptance Criteria fulfillment
Fixes # (issue)
Video/Screenshots
PR Test Details
Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-<pr_number> after approval. Contributors are requested to replace
<pr_number>with the actual PR number.