make restore migration types required (#1977)

This commit is contained in:
David Luzar 2020-07-28 23:40:06 +02:00 committed by GitHub
parent 925db9dcca
commit ab980b252c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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,
};
};

View File

@ -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";