diff --git a/ts/routes/image-occlusion/fabric.d.ts b/ts/routes/image-occlusion/fabric.d.ts new file mode 100644 index 000000000..49fcb78ff --- /dev/null +++ b/ts/routes/image-occlusion/fabric.d.ts @@ -0,0 +1,12 @@ +export {}; + +declare global { + namespace fabric { + interface Object { + id: string; + ordinal: number; + /** a custom property set on groups in the ungrouping routine to avoid adding a spurious undo entry */ + destroyed: boolean; + } + } +} diff --git a/ts/routes/image-occlusion/tools/lib.ts b/ts/routes/image-occlusion/tools/lib.ts index 953ac290e..541c9bb69 100644 --- a/ts/routes/image-occlusion/tools/lib.ts +++ b/ts/routes/image-occlusion/tools/lib.ts @@ -64,12 +64,10 @@ export const groupShapes = (canvas: fabric.Canvas): void => { const activeObject = canvas.getActiveObject() as fabric.ActiveSelection; const items = activeObject.getObjects(); - // @ts-expect-error not defined let minOrdinal: number | undefined = Math.min(...items.map((item) => item.ordinal)); minOrdinal = Number.isNaN(minOrdinal) ? undefined : minOrdinal; items.forEach((item) => { - // @ts-expect-error not defined item.set({ opacity: 1, ordinal: minOrdinal }); }); @@ -90,13 +88,11 @@ export const unGroupShapes = (canvas: fabric.Canvas): void => { const group = canvas.getActiveObject() as fabric.Group; const items = group.getObjects(); group._restoreObjectsState(); - // @ts-expect-error not defined group.destroyed = true; items.forEach((item) => { item.set({ opacity: get(opacityStateStore) ? 0.4 : 1, - // @ts-expect-error not defined ordinal: undefined, }); canvas.add(item); diff --git a/ts/routes/image-occlusion/tools/tool-undo-redo.ts b/ts/routes/image-occlusion/tools/tool-undo-redo.ts index aa073dfe4..96c545d64 100644 --- a/ts/routes/image-occlusion/tools/tool-undo-redo.ts +++ b/ts/routes/image-occlusion/tools/tool-undo-redo.ts @@ -50,7 +50,6 @@ class UndoStack { this.canvas = canvas; this.canvas.on("object:modified", (opts) => this.maybePush(opts)); this.canvas.on("object:removed", (opts) => { - // @ts-expect-error `destroyed` is a custom property set on groups in the ungrouping routine to avoid adding a spurious undo entry if (!opts.target!.group && !opts.target!.destroyed) { this.maybePush(opts); }