Merge pull request #2601 from wbkd/fix/isRectObject

fix(isRectObj): repair test for rect closes #2597
This commit is contained in:
Moritz Klack
2022-11-25 21:50:38 +01:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'@reactflow/core': patch
---
fix isRectObject function

View File

@@ -53,7 +53,8 @@ export const getOverlappingArea = (rectA: Rect, rectB: Rect): number => {
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const isRectObject = (obj: any): obj is Rect => !!obj.width && !!obj.height && !!obj.x && !!obj.y;
export const isRectObject = (obj: any): obj is Rect =>
isNumeric(obj.width) && isNumeric(obj.height) && isNumeric(obj.x) && isNumeric(obj.y);
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const isNumeric = (n: any): n is number => !isNaN(n) && isFinite(n);