From ab980b252c1b8aacead6c70a04dd3168ae4aa216 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Tue, 28 Jul 2020 23:40:06 +0200 Subject: [PATCH] make restore migration types required (#1977) --- src/data/restore.ts | 5 +++-- src/element/newElement.ts | 3 +-- src/element/types.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data/restore.ts b/src/data/restore.ts index e3cfc9eb..ee9e2117 100644 --- a/src/data/restore.ts +++ b/src/data/restore.ts @@ -24,8 +24,8 @@ const getFontFamilyByName = (fontFamilyName: string): FontFamily => { }; function migrateElementWithProperties( - element: T, - extra: Omit, + element: Required, + extra: Omit, keyof ExcalidrawElement>, ): T { const base: Pick = { type: element.type, @@ -93,6 +93,7 @@ const migrateElement = ( [element.width, element.height], ] : element.points, + lastCommittedPoint: null, }); } // generic elements diff --git a/src/element/newElement.ts b/src/element/newElement.ts index bae1792f..c1bd1dae 100644 --- a/src/element/newElement.ts +++ b/src/element/newElement.ts @@ -210,13 +210,12 @@ export const updateTextElement = ( export const newLinearElement = ( opts: { type: ExcalidrawLinearElement["type"]; - lastCommittedPoint?: ExcalidrawLinearElement["lastCommittedPoint"]; } & ElementConstructorOpts, ): NonDeleted => { return { ..._newElementBase(opts.type, opts), points: [], - lastCommittedPoint: opts.lastCommittedPoint || null, + lastCommittedPoint: null, }; }; diff --git a/src/element/types.ts b/src/element/types.ts index de5a9f3c..54e76ba5 100644 --- a/src/element/types.ts +++ b/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";