I have a simple sort:
dataCopy.sort((a: Data, b: Data) => {
if (a[label] === null || b[label] === null) return 0;
if (direction === "desc")
return a[label] > b[label] ? 1 : -1;
return 0;
});
The "Data" type is:
export type Data = {
[key: string]: string | number | null;
};
I check if a[label] and b[label] are both null and I still get the error "Object is possibly 'null'.ts(2531)". It seems to only happen with the > and < operators.