RocketChat / RocketChat/EmbeddedChat

Refactor API: Remove 'any' from EmbeddedChatApi and improve payload typing

Open
#1,237 0 comments 0 reactions 0 assignees View on GitHub

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 any appeared in:
    • message listeners
    • action/ui interaction listeners
    • autoLogin credentials
    • DDP stream callbacks (onStreamData)
    • sendMessage input
    • handleUiKitInteraction input
  • 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 any remains in packages/api/src/EmbeddedChatApi.ts.
  • connect() stream handling uses guarded/narrowed access.
  • sendMessage and handleUiKitInteraction use typed inputs.
  • packages/api builds 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

  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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.