From 1e633f7ed668df67bf892a637be3fc27ac308114 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 3 Aug 2023 15:40:18 +0530 Subject: [PATCH] ts fixes --- src/components/App.tsx | 10 +++++++--- src/data/transform.ts | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 224092e7db..874ee41d78 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -346,7 +346,10 @@ import { activeConfirmDialogAtom } from "./ActiveConfirmDialog"; import { actionWrapTextInContainer } from "../actions/actionBoundText"; import BraveMeasureTextError from "./BraveMeasureTextError"; import { activeEyeDropperAtom } from "./EyeDropper"; -import { convertToExcalidrawElements } from "../data/transform"; +import { + ExcalidrawProgrammaticElement, + convertToExcalidrawElements, +} from "../data/transform"; import { ValueOf } from "../utility-types"; import { isSidebarDockedAtom } from "./Sidebar/Sidebar"; @@ -2288,8 +2291,9 @@ class App extends React.Component { } else if (data.elements) { const elements = ( data.programmaticAPI - ? //@ts-ignore - convertToExcalidrawElements(data.elements) + ? convertToExcalidrawElements( + data.elements as ExcalidrawProgrammaticElement[], + ) : data.elements ) as readonly ExcalidrawElement[]; // TODO remove formatting from elements if isPlainPaste diff --git a/src/data/transform.ts b/src/data/transform.ts index 24da7648f4..40269e70a5 100644 --- a/src/data/transform.ts +++ b/src/data/transform.ts @@ -334,10 +334,14 @@ const bindLinearElementToElement = ( if (end.id) { existingElement = elementStore .getElements() - .find((ele) => ele?.id === end.id) as Exclude< - ExcalidrawBindableElement, - ExcalidrawImageElement | ExcalidrawFrameElement - >; + .find( + ( + ele, + ): ele is Exclude< + ExcalidrawBindableElement, + ExcalidrawImageElement | ExcalidrawFrameElement + > => ele?.id === end.id, + ); if (!existingElement) { console.error(`No element for end binding with id ${end.id} found`); }