-
Notifications
You must be signed in to change notification settings - Fork 78
feat: extend sort with field type #1673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| | AscDesc | ||
| | { | ||
| direction: AscDesc; | ||
| type?: 'string' | 'number'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanat what types will be supported?
|
Size Change: -47 B (-0.01%) Total Size: 356 kB
|
| sortFields.push({ field, direction }); | ||
|
|
||
| export function normalizeQuerySort<T extends Sort<string>>(sort: T | T[]) { | ||
| const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | null }> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | null }> = | |
| const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | number | null }> = |
Not sure, but basing it on this:
https://github.com/GetStream/stream-chat-js/pull/1673/changes#r2664806559
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type is just a string in this case as it's supposed to be sent to the BE, TS should not remove this during compile time. In this case it's just generalized to string so I don't have to do "string" | "number" | "some-other-type-once-added" since we don't really care about specificity at that point.
Description of the changes, What, Why and How?
This PR allows integrators to decide how the target field should be asserted during sorting.
https://getstream.slack.com/archives/C06CF5TKRGA/p1767637494321509?thread_ts=1767298663.322459&cid=C06CF5TKRGA