Skip to content

Commit 6888374

Browse files
committed
feat: improve typing
1 parent 51bc5ef commit 6888374

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/nuxt/src/runtime/composables.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ import {
66
} from 'pinia'
77
export * from 'pinia'
88

9-
export const usePinia = () => useNuxtApp().$pinia
9+
export const usePinia = () => useNuxtApp().$pinia as Pinia | undefined
1010

11-
export const defineStore = (...args) => {
11+
export const defineStore: typeof _defineStore = (
12+
...args: [idOrOptions: any, setup?: any, setupOptions?: any]
13+
) => {
1214
if (!import.meta.server) {
1315
return _defineStore(...args)
1416
}
1517

16-
const store = _defineStore(...args)
17-
18+
const originalUseStore = _defineStore(...args)
1819
function useStore(pinia?: Pinia | null, hot?: StoreGeneric): StoreGeneric {
19-
if (pinia) {
20-
return store(pinia, hot)
21-
}
22-
23-
return store(usePinia(), hot)
20+
return originalUseStore(pinia || usePinia(), hot)
2421
}
2522

23+
useStore.$id = originalUseStore.$id
24+
useStore._pinia = originalUseStore._pinia
25+
2626
return useStore
2727
}

0 commit comments

Comments
 (0)