RocketChat / RocketChat/Rocket.Chat

refactor(livechat): replace any types in Livechat store with proper TypeScript interfaces

Open
#38,337 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Problem

The Livechat store state in
packages/livechat/src/store/index.tsx
uses multiple any type annotations in the StoreState definition, which significantly reduces type safety and developer confidence.

Currently, there are 19 any usages affecting core Livechat state such as messages, alerts, agents, queue info, and configuration settings.

This:

  • Weakens compile-time guarantees
  • Reduces IDE autocompletion and discoverability
  • Makes future refactors riskier
  • Hides potential bugs until runtime

Affected Fields (examples)
messages: any;
triggers: any[];
resources: any;
fileUpload?: any;
allowSwitchingDepartments?: any;
showConnecting?: any;
limitTextLength?: any;
alerts: any[];
unread: any;
incomingCallAlert: any;
businessUnit: any;
modal?: any;
agent?: any;
lastReadMessageId?: any;
triggerAgent?: any;
queueInfo?: any;

(Full list: 19 fields)


Proposed Solution
  • Replace all any annotations in StoreState with proper TypeScript types
  • Reuse existing shared types from @rocket.chat/core-typings where applicable (e.g. IMessage, ILivechatTrigger)
  • Introduce a dedicated types.ts file for Livechat-specific interfaces (alerts, queue info, config objects)
  • Keep changes type-only with no runtime behavior modifications

Benefits
  • Stronger type safety across the Livechat package
  • Better IDE support and autocompletion
  • Earlier detection of state-related bugs at compile time
  • Improved maintainability and confidence for future contributors

Scope
  • Files affected:
    packages/livechat/src/store/index.tsx
    packages/livechat/src/store/types.ts (new)
  • Runtime behavior: unchanged
  • Breaking changes: none

I’m working on this refactor and will open a pull request shortly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with StoreState in packages/livechat/src/store/index.tsx and review the existing shared types mentioned from @rocket.chat/core-typings. Define Livechat-specific interfaces in packages/livechat/src/store/types.ts for the remaining state fields, then replace all 19 any annotations while keeping the changes type-only and runtime behavior unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.