I am working on a function that handles sorting columns
export const handleSortableColumns = (headerKeys: string[], sortKeys: object): string[] => {
if (!headerKeys) return [];
return headerKeys.map((key: string): any => sortKeys[key] || null);
};
The headerKeys parameter accepts a list of strings.
The sortKeys parameter is supposed to be an object
, but I'm not sure about specifying its type since the properties can be different each time. Should I use generics for this? How can I implement it?
Also, the return type should be a list of strings including null values, so what would be the correct return type without using the any keyword?