From 6f063f6a213226c9cfbd25865c66161b5ad9e61c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 20 Jan 2025 21:12:22 +0100 Subject: [PATCH] Type anys --- packages/builder/src/stores/builder/history.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/stores/builder/history.ts b/packages/builder/src/stores/builder/history.ts index 132dcd9ab8..3f9b156498 100644 --- a/packages/builder/src/stores/builder/history.ts +++ b/packages/builder/src/stores/builder/history.ts @@ -51,8 +51,8 @@ export const createHistoryStore = ({ // Wrapped versions of essential functions which we call ourselves when using // undo and redo - let saveFn: any - let deleteFn: any + let saveFn: (doc: T, operationId: string) => Promise + let deleteFn: (doc: T, operationId: string) => Promise /** * Internal util to set the loading flag @@ -113,15 +113,15 @@ export const createHistoryStore = ({ * @param fn the save function * @returns {function} a wrapped version of the save function */ - const wrapSaveDoc = (fn: (doc: any) => Promise) => { - saveFn = async (doc: any, operationId: string) => { + const wrapSaveDoc = (fn: (doc: T) => Promise) => { + saveFn = async (doc: T, operationId: string) => { // Only works on a single doc at a time if (!doc || Array.isArray(doc)) { return } startLoading() try { - const oldDoc = getDoc(doc._id) + const oldDoc = getDoc(doc._id!) const newDoc = jsonpatch.deepClone(await fn(doc)) // Store the change @@ -161,8 +161,8 @@ export const createHistoryStore = ({ * @param fn the delete function * @returns {function} a wrapped version of the delete function */ - const wrapDeleteDoc = (fn: (doc: any) => Promise) => { - deleteFn = async (doc: any, operationId: string) => { + const wrapDeleteDoc = (fn: (doc: T) => Promise) => { + deleteFn = async (doc: T, operationId: string) => { // Only works on a single doc at a time if (!doc || Array.isArray(doc)) { return