RocketChat / RocketChat/Rocket.Chat
refactor: Convert spotlight.js to TypeScript and remove object mutations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Background
The module apps/meteor/server/lib/spotlight.js powers the user and room autocomplete search functionality.
It appears to be one of the remaining plain JavaScript files in server/lib/, which is otherwise TypeScript-based.
Observations
- The file is ~280 lines of untyped JavaScript.
processLimitAndUsernames()mutatesoptions.limitand theusernamesarray in-place.fetchRooms()usesdelete room.lastMessage, which mutates returned MongoDB documents.- There are currently no unit tests covering this module.
Proposal
I would like to prepare a refactor PR that:
- Renames
spotlight.js→spotlight.ts - Introduces explicit TypeScript interfaces for search parameters and return types
- Replaces in-place mutations with pure transformations
- Avoids
deleteon return objects by using object destructuring - Preserves all existing behavior (no functional changes)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading apps/meteor/server/lib/spotlight.js, focusing on processLimitAndUsernames() and fetchRooms(). Confirm the current user and room autocomplete behavior before renaming it to spotlight.ts. Done means explicit TypeScript interfaces, pure transformations instead of object or array mutations, no delete on returned documents, and preserved behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- backend, search
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100