typescript - Zustand deposundaki `set` metodunu Immer ara yazılımı ile otomatik tamamlama özelliğini koruyarak yazmak


Immer ara yazılımını kullanırken Zustand deposundaki set metodunu yazarken sorun yaşıyorum. Bazı özellikler durumu güncelleyecek fonksiyonlar içerdiği için onu yazmam gerekiyor, bu yüzden set fonksiyonuna ihtiyaçları var:

export const useStore = create<Store>()(
     immer((set, get) => ({
         func: beginDraggingVertex(set, get, vertexID) 
     }))
)     

....

function beginDraggingVertex(set: Setter, get: Getter, vertexID: string) {
  ...ommited
  set((store) => 
   // here is where I do want to have the autocomplete working
   store.whateverProperty = 'hi'
  )

}

Eğer depodan Immer ara yazılımını kaldırırsam, set metodunun üzerine geldiğimde tipini alabiliyorum, böylece daha sonra beginDraggingVertex bildirimi argümanlarına tip verebiliyorum. Ama Immer uygulandığında, set metodu değişiyor ve eğer set tipini yeni tipe değiştirirsem, otomatik tamamlama kayboluyor.

 //`set` type with Immer applied, with this one I loose autocomplete wihtin:
 type Setter = (
  nextStateOrUpdater:
    | (Store & ActionsObject)
    | Partial<Store & ActionsObject>
    | ((state: WritableDraft<Store & ActionsObject>) => void),
  shouldReplace?: boolean | undefined
) => void

//`set` type without Immer:
 export type Setter = (
  partial:
    | (Store & ActionsObject)
    | Partial<Store & ActionsObject>
    | ((state: Store & ActionsObject) => (Store & ActionsObject) | Partial<Store & ActionsObject>),
  replace?: boolean | undefined
) => void


Eğer Immer uygular ve sonra set'e önceden uygulanmamış eski tipi verirsem, elbette otomatik tamamlama alırım ama set geri çağrısında bu hataları da alırım:

I was expecting (Store & ActionsObject) | Partial<Store & ActionsObject> | ((state: Store & ActionsObject) => (Store & ActionsObject) | Partial<...>), but you passed (store: Store & ActionsObject) => void

Sağlayabileceğiniz her türlü yardımı gerçekten takdir ediyorum.