Type anys

This commit is contained in:
Adria Navarro 2025-01-20 21:12:22 +01:00
parent 25d450602f
commit 6f063f6a21
1 changed files with 7 additions and 7 deletions

View File

@ -51,8 +51,8 @@ export const createHistoryStore = <T extends Document>({
// Wrapped versions of essential functions which we call ourselves when using // Wrapped versions of essential functions which we call ourselves when using
// undo and redo // undo and redo
let saveFn: any let saveFn: (doc: T, operationId: string) => Promise<T>
let deleteFn: any let deleteFn: (doc: T, operationId: string) => Promise<void>
/** /**
* Internal util to set the loading flag * Internal util to set the loading flag
@ -113,15 +113,15 @@ export const createHistoryStore = <T extends Document>({
* @param fn the save function * @param fn the save function
* @returns {function} a wrapped version of the save function * @returns {function} a wrapped version of the save function
*/ */
const wrapSaveDoc = (fn: (doc: any) => Promise<void>) => { const wrapSaveDoc = (fn: (doc: T) => Promise<void>) => {
saveFn = async (doc: any, operationId: string) => { saveFn = async (doc: T, operationId: string) => {
// Only works on a single doc at a time // Only works on a single doc at a time
if (!doc || Array.isArray(doc)) { if (!doc || Array.isArray(doc)) {
return return
} }
startLoading() startLoading()
try { try {
const oldDoc = getDoc(doc._id) const oldDoc = getDoc(doc._id!)
const newDoc = jsonpatch.deepClone(await fn(doc)) const newDoc = jsonpatch.deepClone(await fn(doc))
// Store the change // Store the change
@ -161,8 +161,8 @@ export const createHistoryStore = <T extends Document>({
* @param fn the delete function * @param fn the delete function
* @returns {function} a wrapped version of the delete function * @returns {function} a wrapped version of the delete function
*/ */
const wrapDeleteDoc = (fn: (doc: any) => Promise<void>) => { const wrapDeleteDoc = (fn: (doc: T) => Promise<void>) => {
deleteFn = async (doc: any, operationId: string) => { deleteFn = async (doc: T, operationId: string) => {
// Only works on a single doc at a time // Only works on a single doc at a time
if (!doc || Array.isArray(doc)) { if (!doc || Array.isArray(doc)) {
return return