Prevent using <any> in custom sort function
Below custom sort function in isolated file
My question: any pointers on how to replace the <any> type on line 5 with something more strict?
fuzzy-sort.tsfuzzy-sort.ts works as expected.My question: any pointers on how to replace the <any> type on line 5 with something more strict?
import { compareItems } from "@tanstack/match-sorter-utils";
import { SortingFn, sortingFns } from "@tanstack/react-table";
// Define a custom fuzzy sort function that will sort by rank if the row has ranking information
export const fuzzySort: SortingFn<any> | undefined = (rowA, rowB, columnId) => {
let dir = 0;
// Only sort by rank if the column has ranking information
if (rowA.columnFiltersMeta[columnId]) {
dir = compareItems(
rowA.columnFiltersMeta[columnId]?.itemRank,
rowB.columnFiltersMeta[columnId]?.itemRank,
);
}
// Provide an alphanumeric fallback for when the item ranks are equal
return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir;
};
export default fuzzySort;import { compareItems } from "@tanstack/match-sorter-utils";
import { SortingFn, sortingFns } from "@tanstack/react-table";
// Define a custom fuzzy sort function that will sort by rank if the row has ranking information
export const fuzzySort: SortingFn<any> | undefined = (rowA, rowB, columnId) => {
let dir = 0;
// Only sort by rank if the column has ranking information
if (rowA.columnFiltersMeta[columnId]) {
dir = compareItems(
rowA.columnFiltersMeta[columnId]?.itemRank,
rowB.columnFiltersMeta[columnId]?.itemRank,
);
}
// Provide an alphanumeric fallback for when the item ranks are equal
return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir;
};
export default fuzzySort;