AttachmentDraftsStoreApi: improve typing

This commit is contained in:
Enrico Ros
2025-01-09 17:18:05 -08:00
parent 59966546cf
commit b1d94e790f
2 changed files with 5 additions and 6 deletions
@@ -1,10 +1,9 @@
import type { StoreApi } from 'zustand';
import { createStore as createVanillaStore } from 'zustand/vanilla';
import { AttachmentsDraftsStore, createAttachmentDraftsStoreSlice } from './store-attachment-drafts_slice';
import { AttachmentDraftsStoreApi, AttachmentsDraftsStore, createAttachmentDraftsStoreSlice } from './store-attachment-drafts_slice';
export const createAttachmentDraftsVanillaStore = (): StoreApi<AttachmentsDraftsStore> => createVanillaStore<AttachmentsDraftsStore>()((...a) => ({
export const createAttachmentDraftsVanillaStore = (): AttachmentDraftsStoreApi => createVanillaStore<AttachmentsDraftsStore>()((...a) => ({
// Attachments: attachment drafts
...createAttachmentDraftsStoreSlice(...a),
@@ -15,5 +14,5 @@ export const createAttachmentDraftsVanillaStore = (): StoreApi<AttachmentsDrafts
// const _fallbackStoreApi = createPerChatVanillaStore();
// // usages: useAttachmentDrafts
// export const useChatAttachmentsStore = <T, >(vanillaStore: Readonly<StoreApi<AttachmentsDraftsStore>> | null, selector: (store: AttachmentsDraftsStore) => T): T =>
// export const useChatAttachmentsStore = <T, >(vanillaStore: Readonly<AttachmentDraftsStoreApi> | null, selector: (store: AttachmentsDraftsStore) => T): T =>
// useStore(vanillaStore || fallbackStoreApi, selector);
@@ -1,7 +1,7 @@
import { StoreApi, useStore } from 'zustand';
import { createStore as createVanillaStore } from 'zustand/vanilla';
import { AttachmentsDraftsStore, createAttachmentDraftsStoreSlice } from '~/common/attachment-drafts/store-attachment-drafts_slice';
import { AttachmentDraftsStoreApi, AttachmentsDraftsStore, createAttachmentDraftsStoreSlice } from '~/common/attachment-drafts/store-attachment-drafts_slice';
import { ComposerOverlayStore, createComposerOverlayStoreSlice } from './store-perchat-composer_slice';
import { createEphemeralsOverlayStoreSlice, EphemeralsOverlayStore } from './store-perchat-ephemerals_slice';
@@ -41,7 +41,7 @@ export const useChatOverlayStore = <T, >(vanillaStore: Readonly<StoreApi<PerChat
useStore(vanillaStore || fallbackStoreApi, selector);
// usages: useAttachmentDrafts
export const useChatAttachmentsStore = <T, >(vanillaStore: Readonly<StoreApi<AttachmentsDraftsStore>> | null, selector: (store: AttachmentsDraftsStore) => T): T =>
export const useChatAttachmentsStore = <T, >(vanillaStore: Readonly<AttachmentDraftsStoreApi> | null, selector: (store: AttachmentsDraftsStore) => T): T =>
useStore(vanillaStore || fallbackStoreApi, selector);
// usages: Composer