Browse Source

make restore migration types required (#1977)

David Luzar 5 năm trước cách đây
mục cha
commit
ab980b252c
3 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 3 2
      src/data/restore.ts
  2. 1 2
      src/element/newElement.ts
  3. 1 1
      src/element/types.ts

+ 3 - 2
src/data/restore.ts

@@ -24,8 +24,8 @@ const getFontFamilyByName = (fontFamilyName: string): FontFamily => {
 };
 
 function migrateElementWithProperties<T extends ExcalidrawElement>(
-  element: T,
-  extra: Omit<T, keyof ExcalidrawElement>,
+  element: Required<T>,
+  extra: Omit<Required<T>, keyof ExcalidrawElement>,
 ): T {
   const base: Pick<T, keyof ExcalidrawElement> = {
     type: element.type,
@@ -93,6 +93,7 @@ const migrateElement = (
                 [element.width, element.height],
               ]
             : element.points,
+        lastCommittedPoint: null,
       });
     }
     // generic elements

+ 1 - 2
src/element/newElement.ts

@@ -210,13 +210,12 @@ export const updateTextElement = (
 export const newLinearElement = (
   opts: {
     type: ExcalidrawLinearElement["type"];
-    lastCommittedPoint?: ExcalidrawLinearElement["lastCommittedPoint"];
   } & ElementConstructorOpts,
 ): NonDeleted<ExcalidrawLinearElement> => {
   return {
     ..._newElementBase<ExcalidrawLinearElement>(opts.type, opts),
     points: [],
-    lastCommittedPoint: opts.lastCommittedPoint || null,
+    lastCommittedPoint: null,
   };
 };
 

+ 1 - 1
src/element/types.ts

@@ -67,7 +67,7 @@ export type ExcalidrawLinearElement = _ExcalidrawElementBase &
   Readonly<{
     type: "arrow" | "line" | "draw";
     points: readonly Point[];
-    lastCommittedPoint?: Point | null;
+    lastCommittedPoint: Point | null;
   }>;
 
 export type PointerType = "mouse" | "pen" | "touch";