Skip to content
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

tsify ColumnComparer #1576

Merged
merged 1 commit into from Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions packages/react-data-grid/src/ColumnComparer.js

This file was deleted.

24 changes: 24 additions & 0 deletions packages/react-data-grid/src/ColumnComparer.ts
@@ -0,0 +1,24 @@
import { isElement } from 'react-is';

export function sameColumn<A, B>(a: A, b: B): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably replace the generic types once we know how this function is used.

for (const k in a) {
if (a.hasOwnProperty(k)) {
const valA = a[k] as unknown;
const valB = b[k as string as keyof B] as unknown;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the as string as keyof B part:
image

Without at least one as unknown:
image

if ((typeof valA === 'function' && typeof valB === 'function') || (isElement(valA) && isElement(valB))) {
continue;
}
if (!b.hasOwnProperty(k) || valA !== valB) {
return false;
}
}
}

for (const k in b) {
if (b.hasOwnProperty(k) && !a.hasOwnProperty(k)) {
return false;
}
}

return true;
}