Skip to content

Commit b35e26a

Browse files
author
allen
committed
chore: update
1 parent 3c45a08 commit b35e26a

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"eslint-plugin-cypress": "3.5.0",
4949
"eslint-plugin-format": "0.1.2",
5050
"husky": "7.0.4",
51-
"pinia-auto-refs": "0.0.10",
51+
"pinia-auto-refs": "0.0.12",
5252
"postcss-html": "1.4.1",
5353
"postcss-scss": "4.0.4",
5454
"sass": "1.52.3",

src/helper/pinia-auto-refs.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
/* eslint-disable */
33
/* prettier-ignore */
44
// @ts-nocheck
5-
import type { AutoToRefs, ToRef } from 'vue'
5+
import type { ToRef, UnwrapRef } from 'vue'
6+
import { storeToRefs } from 'pinia'
67

78
import appStore from '@/store/app'
89
import testStore from '@/store/test'
910
import userStore from '@/store/user'
1011

1112
import store from '@/store'
1213

13-
declare module 'vue' {
14-
export type AutoToRefs<T> = {
15-
[K in keyof T]: T[K] extends Function ? T[K] : ToRef<T[K]>
16-
}
14+
type StoreToRefs<T extends StoreDefinition> = {
15+
[K in keyof ReturnType<T>]: ReturnType<T>[K] extends Function
16+
? ReturnType<T>[K]
17+
: ToRef<UnwrapRef<ReturnType<T>[K]>>
1718
}
1819

1920
const storeExports = {
@@ -25,5 +26,5 @@ const storeExports = {
2526
export function useStore<T extends keyof typeof storeExports>(storeName: T) {
2627
const targetStore = storeExports[storeName](store)
2728
const storeRefs = storeToRefs(targetStore)
28-
return { ...targetStore, ...storeRefs } as unknown as AutoToRefs<ReturnType<typeof storeExports[T]>>
29+
return { ...targetStore, ...storeRefs } as StoreToRefs<(typeof storeExports)[T]>
2930
}

0 commit comments

Comments
 (0)