Skip to content

Commit

Permalink
feat: improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
pguilbert committed Dec 13, 2024
1 parent 51bc5ef commit 6888374
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/nuxt/src/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import {
} from 'pinia'
export * from 'pinia'

export const usePinia = () => useNuxtApp().$pinia
export const usePinia = () => useNuxtApp().$pinia as Pinia | undefined

export const defineStore = (...args) => {
export const defineStore: typeof _defineStore = (
...args: [idOrOptions: any, setup?: any, setupOptions?: any]
) => {
if (!import.meta.server) {
return _defineStore(...args)
}

const store = _defineStore(...args)

const originalUseStore = _defineStore(...args)
function useStore(pinia?: Pinia | null, hot?: StoreGeneric): StoreGeneric {
if (pinia) {
return store(pinia, hot)
}

return store(usePinia(), hot)
return originalUseStore(pinia || usePinia(), hot)
}

useStore.$id = originalUseStore.$id
useStore._pinia = originalUseStore._pinia

return useStore
}

0 comments on commit 6888374

Please sign in to comment.