Skip to content

fix: adapt to removed stream-chat-js hand-written types - #3274

Draft
szuperaz wants to merge 2 commits into
release-v15from
reduce-hand-written-types-in-js-client
Draft

fix: adapt to removed stream-chat-js hand-written types#3274
szuperaz wants to merge 2 commits into
release-v15from
reduce-hand-written-types-in-js-client

Conversation

@szuperaz

@szuperaz szuperaz commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Not yet ready to be merged

Relevant stream-chat-js PR: GetStream/stream-chat-js#1836

🎯 Goal

Describe why we are making this change

πŸ›  Implementation details

Provide a description of the implementation

🎨 UI Changes

Add relevant screenshots

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fa923b9f-febe-42b9-bba8-8fff05758647

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

`stream-chat` collapsed the twelve `*Sort` aliases, which were all exactly
`SortParamRequest[]` β€” twelve names for one type β€” and retired the `APIResponse`-based
response aliases in favour of the generated response types.

* `ReactionSort` -> `SortParamRequest[]` across 13 sites in 5 files. Note the brackets:
  the alias *was* the array, so this is not `SortParamRequest`. Four of the sites are
  public API and change the emitted `.d.ts`: `MessageContextValue.handleFetchReactions`
  and `.reactionDetailsSort`, `MessageProps.reactionDetailsSort`,
  `MessageReactionsDetailProps.sort`, and `FetchReactionsOptions.sort`. The type is
  structurally identical, so no consumer code needs to change β€” only the name they
  import if they annotate it themselves.

* `ChannelSort` -> `SortParamRequest[]` in the tutorial and vite examples.

* `SendFileAPIResponse` -> `Awaited<ReturnType<Channel['uploadImage' | 'uploadFile']>>`
  in the two test files that annotated upload spies, following the `ReturnType<…>` idiom
  already used for `markRead` in 7842c17 so these track the method rather than a name.
  Deriving from the method also drops `SendFileAPIResponse`'s claim that `file` is
  required β€” the generated `FileUploadResponse.file` is optional. That was always true of
  the real response; the alias was hiding it.

* `useSendMessageFn` no longer casts `message` to `MessageRequest`. `compose()` used to
  widen it to `MessageRequest | UpdatedMessage` and the cast narrowed it back; the union
  is gone, so the cast and its explanatory comment are both dead.

Docs: `AI.md` also had a stale `const sort: ChannelSort = { last_message_at: -1 }` β€” the
v9 keyed-object form, which stopped being valid when sort became an array. Corrected
alongside the rename. `specs/message-pagination/decisions.md` referenced
`channel.getReplies(...)`, which `stream-chat` removed in favour of `client.getReplies()`.

Verified: `tsc -p tsconfig.lib.json` clean, 2828 tests passing, eslint clean on every
touched file.

Note on `yarn types`: the root `tsconfig.json` is solution-style (`"files": []` plus
`references`), so `tsc --noEmit` without `--build` typechecks nothing and the script
passes unconditionally. The real check is `tsc -p tsconfig.lib.json`. Left alone here as
it is a pre-existing issue unrelated to this change.

Note on `yarn types:tests`: already failing before this change with ~1216 errors, none
of them from this migration β€” `ChannelAPIResponse`, `QueryChannelAPIResponse`,
`MuteChannelAPIResponse`, `AppSettingsAPIResponse` and several stream-chat-react-local
context types were removed by earlier v10 work and never migrated in the test tree. This
change takes that count down by 2 and adds none.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@szuperaz
szuperaz force-pushed the reduce-hand-written-types-in-js-client branch from 207db88 to a2b4ccb Compare August 20, 2026 14:41
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-v15@04a31b1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...MemberDetailView/ChannelMemberActions.defaults.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release-v15    #3274   +/-   ##
==============================================
  Coverage               ?   84.46%           
==============================================
  Files                  ?      526           
  Lines                  ?    15940           
  Branches               ?     5109           
==============================================
  Hits                   ?    13463           
  Misses                 ?     2477           
  Partials               ?        0           

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

`stream-chat` removed the hand-written `/moderation/*` methods from `StreamChat` in favour
of the generated V2 moderation API, reachable as `client.moderation`.

* `client.muteUser(id)`   -> `client.moderation.mute({ target_ids: [id] })`
* `client.unmuteUser(id)` -> `client.moderation.unmute({ target_ids: [id] })`
* `client.flagMessage(id)` -> `client.moderation.flagMessage(id)`

V2 mute/unmute take `target_ids` as an array, hence the wrapping. `flagMessage` keeps its
`(messageId)` shape because the moderation wrapper supplies the entity type, and `reason`
is optional there.

Call sites: `useMuteHandler`, `useFlagHandler`, and the mute toggles in
`ChannelManagementActions.defaults` and `ChannelMemberActions.defaults`.

`channel.banUser` / `channel.unbanUser` are unchanged β€” `Channel` keeps those wrappers, and
`unbanUser` has no generated equivalent so it stays on v1 upstream.

No public API change: none of these responses were read, and no exported type or prop
signature moves.

Tests: the spies moved from `client.muteUser` / `client.unmuteUser` / `client.flagMessage`
to their `client.moderation` counterparts, and the mute assertions expect
`{ target_ids: [id] }` rather than a bare id. The hoisted mock client in
`ChannelManagementActions.defaults.test` grows a `moderation` object for the same reason.

Verified: `tsc -p tsconfig.lib.json` clean, 2828 tests passing, eslint clean on every
touched file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@szuperaz szuperaz changed the title Reduce hand written types in js client fix: adapt to removed stream-chat-js hand-written types Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant