RocketChat / RocketChat/EmbeddedChat
Refactor API: Remove 'any' from EmbeddedChatApi and improve payload typing
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
Summary
packages/api/src/EmbeddedChatApi.ts currently relies on multiple explicit any types across callback signatures, stream payload handling, auth inputs, and message APIs. This reduces type safety and makes it easier to accidentally access unsafe or undefined fields, especially when working with dynamic DDP payloads.
Problem
- Explicit
anyappeared in:- message listeners
- action/ui interaction listeners
autoLogincredentials- DDP stream callbacks (
onStreamData) sendMessageinputhandleUiKitInteractioninput
- Stream payloads were accessed without defensive narrowing (
fields,eventName,args). - SDK callback types are broad, so local guards are needed to keep runtime behavior while improving static safety.
Acceptance Criteria
- No explicit
anyremains inpackages/api/src/EmbeddedChatApi.ts. connect()stream handling uses guarded/narrowed access.sendMessageandhandleUiKitInteractionuse typed inputs.packages/apibuilds successfully.- No lint/type errors introduced.
Impact
- Better type safety and editor intelligence.
- Lower risk of runtime errors from malformed DDP payloads.
- No intended behavior changes at runtime.
Contributor guide
No contributing guide indexed for this repository
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 with packages/api/src/EmbeddedChatApi.ts, reading connect(), the callback signatures, autoLogin, sendMessage, and handleUiKitInteraction. Run the packages/api build and lint/type checks while replacing explicit any with typed inputs and guarded stream access; done means no explicit any remains and the package builds without new errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100