You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I'd prefer not to write my custom sort directly in line with the column definition. It's used in multiple places, so I'd like to write it out in a utility file and import it where needed.
The first two parameters for MRT_SortingFn are Row<T>, but Row<T> isn't exported. Since Typescript doesn't seem capable of doing anything like this: const thing: Something<T> = <T,>(whatever: T) => {} (Cannot find name T), I have to extract the type for Row from the exported MRT_SortingFn<T> like so:
type MRTSortFn<T extends object> = Exclude<MRT_SortingFn<T>, MRT_SortingOption> type Row<T extends object> = Parameters<MRTSortFn<T>>[0]
That works, and everything is fine and dandy from there on out, but I'm thinking it'd be much better DX to export the type for Row<T>. That, or I'm missing something.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am writing a custom sorting function according to the guide: https://v2.mantine-react-table.com/docs/guides/sorting#add-custom-sorting-functions
However, I'd prefer not to write my custom sort directly in line with the column definition. It's used in multiple places, so I'd like to write it out in a utility file and import it where needed.
The first two parameters for
MRT_SortingFn
areRow<T>
, butRow<T>
isn't exported. Since Typescript doesn't seem capable of doing anything like this:const thing: Something<T> = <T,>(whatever: T) => {}
(Cannot find nameT
), I have to extract the type forRow
from the exportedMRT_SortingFn<T>
like so:type MRTSortFn<T extends object> = Exclude<MRT_SortingFn<T>, MRT_SortingOption>
type Row<T extends object> = Parameters<MRTSortFn<T>>[0]
That works, and everything is fine and dandy from there on out, but I'm thinking it'd be much better DX to export the type for
Row<T>
. That, or I'm missing something.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions