Skip to content

Commit

Permalink
refactor: simplify types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 28, 2024
1 parent c8cbfae commit 61b47e8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/pinia/src/mapHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentPublicInstance, ComputedRef } from 'vue-demi'
import type { ComponentPublicInstance, ComputedRef, UnwrapRef } from 'vue-demi'
import type {
_GettersTree,
_Method,
Expand Down Expand Up @@ -431,7 +431,7 @@ export function mapActions<
/**
* For internal use **only**
*/
export type _MapWritableStateReturn<S extends StateTree> = {
export type _MapWritableStateReturn<S> = {
[key in keyof S]: {
get: () => S[key]
set: (value: S[key]) => any
Expand All @@ -442,7 +442,7 @@ export type _MapWritableStateReturn<S extends StateTree> = {
* For internal use **only**
*/
export type _MapWritableStateObjectReturn<
S extends StateTree,
S,
T extends Record<string, keyof S>,
> = {
[key in keyof T]: {
Expand All @@ -464,12 +464,11 @@ export function mapWritableState<
S extends StateTree,
G extends _GettersTree<S>,
A,
KeyMapper extends Record<string, keyof S>,
SS extends StateTree = Store<Id, S, G, A>,
KeyMapper extends Record<string, keyof UnwrapRef<S>>,
>(
useStore: StoreDefinition<Id, S, G, A>,
keyMapper: KeyMapper
): Pick<_MapWritableStateObjectReturn<SS, KeyMapper>, keyof KeyMapper>
): _MapWritableStateObjectReturn<UnwrapRef<S>, KeyMapper>
/**
* Allows using state and getters from one store without using the composition
* API (`setup()`) by generating an object to be spread in the `computed` field
Expand All @@ -483,12 +482,11 @@ export function mapWritableState<
S extends StateTree,
G extends _GettersTree<S>,
A,
Keys extends keyof S,
SS extends StateTree = Store<Id, S, G, A>,
Keys extends keyof UnwrapRef<S>,
>(
useStore: StoreDefinition<Id, S, G, A>,
keys: readonly Keys[]
): Pick<_MapWritableStateReturn<SS>, Keys>
): Pick<_MapWritableStateReturn<UnwrapRef<S>>, Keys>
/**
* Allows using state and getters from one store without using the composition
* API (`setup()`) by generating an object to be spread in the `computed` field
Expand Down

0 comments on commit 61b47e8

Please sign in to comment.