fix: adapt to removed stream-chat-js hand-written types - #3783
Draft
szuperaz wants to merge 2 commits into
Draft
Conversation
`stream-chat` collapsed the twelve `*Sort` aliases β all of them exactly
`SortParamRequest[]`, twelve names for one type β and dropped several aliases that either
restated a generated type or added a restriction the generated model does not have.
Sort aliases -> `SortParamRequest[]` (note the brackets: the alias *was* the array):
* `ChannelSort` in 8 files, including two public surfaces β
`ChannelListEventListenerOptions.sort` (exported via `package/src/index.ts`) and
`ChannelList`'s `sort` prop.
* `ReactionSort` in 4 files, including `useFetchReactions`' public `sort` param.
* `DraftSort` in the SampleApp draft manager.
Restated aliases -> the generated type they restated:
* `PollResponse_old` -> `PollResponseData` in the three offline-store poll files. Note
this is `PollResponseData`, NOT the `PollResponse` that tsc suggests β `PollResponse` is
the `{ duration, poll }` envelope, a different type.
* `ChannelData` -> `ChannelInput`.
* `Pager` -> inlined as `limit` / `next` / `prev` on the SampleApp's own options bag.
`LiveLocationPayload` -> `SharedLocation`, which is a real behavioural correction rather
than a rename. The old alias was `RequireLiteral<SharedLocation, 'end_at'>`, i.e. it made
`end_at` required β an extra restriction the generated model does not carry, because a
*static* shared location legitimately has no expiry. `useMessagePreviewText` was written
against that false guarantee. It already tested `end_at` for truthiness, but did so
through two separate cast expressions, so the narrowing did not carry to the `new Date()`
call. Reads the field into a local now, which both narrows correctly and drops the
duplicated cast.
`CommandVariants` was removed and deliberately not replaced with an equivalent local
union. It is genuinely hand-written β eight literals plus `keyof CustomCommandData`, with
no generated backing β so keeping a copy here would just relocate the problem. Both uses
are better served without it:
* `AutoCompleteSuggestionCommandIcon` takes `name: string`. It maps a command name to one
of *our* icons and already ends in an `else` fallback for anything unrecognised, so
`string` is what it actually accepts. It also branched on `'flag'` and `'imgur'`, which
`CommandVariants` never contained.
* `AutoCompleteSuggestionItem` no longer needs `name as CommandVariants` β `name` is
already a string.
Also, while in the area:
* `usePollState` drops the `APIResponse &` intersections from `addComment` and `endVote`.
The generated response types already carry `duration`, and `APIResponse` is scheduled
for removal along with the hand-written `/moderation/*` methods. Doing it now avoids a
second edit to this exported type.
* `channelMocks` used `type: 'MessageLabel'` for three mocked messages β the *type name*
pasted where a value belonged, which is not a valid message type. Now `'regular'`.
* `generator/channel.ts` pins `automod` / `automod_behavior` with `as const`. Both are
narrow unions now (`Automod`, `AutomodBehavior` lost their `| (string & {})` tails), and
a bare object literal widens them to `string`.
* `Channel.tsx` JSDoc no longer refers to the removed `UpdatedMessage`.
Verified against a local build of the stream-chat branch:
* `tsc -p tsconfig.test.json` in `package/`: clean (was 20 errors).
* Root `yarn typecheck`: 130 -> 108 errors. All 22 fixed are the ones above; none
introduced. The two that appear to be new are the pre-existing
`Property 'logger' does not exist on type 'StreamChat'` pair in `DraftsManager.ts`,
shifted 3 lines by the reformatted import.
* `yarn lint`: clean.
* `yarn test:unit`: 38 suites / 289 tests fail both with and without these changes β
byte-identical failing-suite lists. That debt predates this work; the repo was never
adapted to `10.0.0-rc.4` (the version-bump commit changed only `package.json` and
`yarn.lock`). No regressions from this change.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
SDK Size
|
`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.banUser(id)` -> `client.moderation.ban({ target_user_id: id })`
* `client.flagMessage(id)` -> `client.moderation.flagMessage(id)`
V2 mute/unmute take `target_ids` as an array, hence the wrapping. The ban call stays
unscoped, matching the app-wide ban it performed before β note this differs from
stream-chat-react, which bans through `channel.banUser` and is therefore channel-scoped.
Call sites: `useMessageActionHandlers` (mute, unmute, ban, flag), `useChannelActions` and
`useUserActions` (mute, unmute).
`client.unbanUser` is unchanged β it has no generated equivalent upstream and keeps its v1
implementation.
No public API change: none of these responses were read, and no exported type or prop
signature moves.
Tests: the mock client in `useUserActions.test` exposes `moderation: { mute, unmute }`
instead of top-level `muteUser` / `unmuteUser`, and its assertions expect
`{ target_ids: [id] }` rather than a bare id.
Verified: `tsc --noEmit -p tsconfig.test.json` clean, `yarn lint` clean, and `yarn test:unit`
matches its pre-change baseline exactly β 38 suites / 289 tests failing before and after,
all pre-existing (this repo was never adapted to stream-chat 10.0.0-rc.4). No regressions.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not yet ready to be merged
Relevant stream-chat-js PR: GetStream/stream-chat-js#1836
π― Goal
π Implementation details
π¨ UI Changes
iOS
Android
π§ͺ Testing
βοΈ Checklist
developbranch