Type anys
This commit is contained in:
parent
25d450602f
commit
6f063f6a21
|
@ -51,8 +51,8 @@ export const createHistoryStore = <T extends Document>({
|
|||
|
||||
// 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<T>
|
||||
let deleteFn: (doc: T, operationId: string) => Promise<void>
|
||||
|
||||
/**
|
||||
* Internal util to set the loading flag
|
||||
|
@ -113,15 +113,15 @@ export const createHistoryStore = <T extends Document>({
|
|||
* @param fn the save function
|
||||
* @returns {function} a wrapped version of the save function
|
||||
*/
|
||||
const wrapSaveDoc = (fn: (doc: any) => Promise<void>) => {
|
||||
saveFn = async (doc: any, operationId: string) => {
|
||||
const wrapSaveDoc = (fn: (doc: T) => Promise<void>) => {
|
||||
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 = <T extends Document>({
|
|||
* @param fn the delete function
|
||||
* @returns {function} a wrapped version of the delete function
|
||||
*/
|
||||
const wrapDeleteDoc = (fn: (doc: any) => Promise<void>) => {
|
||||
deleteFn = async (doc: any, operationId: string) => {
|
||||
const wrapDeleteDoc = (fn: (doc: T) => Promise<void>) => {
|
||||
deleteFn = async (doc: T, operationId: string) => {
|
||||
// Only works on a single doc at a time
|
||||
if (!doc || Array.isArray(doc)) {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue