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

Đang mở
#1,237 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
api, developer-experience

Hướng nghiên cứu

Bắt đầu với packages/api/src/EmbeddedChatApi.ts, đọc connect(), các chữ ký callback, autoLogin, sendMessage và handleUiKitInteraction. Chạy build và các bước kiểm tra lint/type của packages/api trong khi thay thế any tường minh bằng các đầu vào có kiểu và quyền truy cập stream có kiểm tra; hoàn tất nghĩa là không còn any tường minh nào và package build thành công mà không có lỗi mới.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
JavaScript
Star
165
Fork
381
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RocketChat/EmbeddedChat

Tất cả issue của RocketChat/EmbeddedChat

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.