]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: any type to correctly infer
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 28 Apr 2021 17:03:41 +0000 (19:03 +0200)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Wed, 28 Apr 2021 17:45:38 +0000 (19:45 +0200)
src/index.ts
src/mapHelpers.ts
test-dts/plugins.test-d.ts

index 6a09a0ce481222a5d9eafb544f86fb2b9c2c9e20..1b1aad1cbaeb01537a15592ebc0dc34ea863c903 100644 (file)
@@ -10,7 +10,6 @@ export {
   StateTree,
   Store,
   GenericStore,
-  GenericStoreDefinition,
   StoreDefinition,
   StoreWithGetters,
   StoreWithActions,
index 5763699a52ca23264f601cf0794c9150492aa5c3..1962d6e0c12420d41826582e56c8198a52466518 100644 (file)
@@ -1,7 +1,6 @@
 import { ComponentInstance } from '@vue/devtools-api'
 import {
   GenericStore,
-  GenericStoreDefinition,
   Method,
   StateTree,
   Store,
@@ -99,7 +98,7 @@ export function setMapStoreSuffix(
  *
  * @param stores - list of stores to map to an object
  */
-export function mapStores<Stores extends GenericStoreDefinition[]>(
+export function mapStores<Stores extends any[]>(
   ...stores: [...Stores]
 ): Spread<Stores> {
   return stores.reduce((reduced, useStore) => {
@@ -426,6 +425,7 @@ export function mapWritableState<
 ): MapWritableStateReturn<S> | MapWritableStateObjectReturn<S, KeyMapper> {
   return Array.isArray(keysOrMapper)
     ? keysOrMapper.reduce((reduced, key) => {
+        // @ts-ignore
         reduced[key] = {
           get(this: ComponentInstance) {
             return getCachedStore(this, useStore)[key]
index c1d542e2fbbee156eed15e7e700c3dbdb9fe109e..aab882e88a12a73c31f0dfce3cf0187833c42167 100644 (file)
@@ -1,23 +1,4 @@
-import {
-  defineStore,
-  expectType,
-  mapStores,
-  createPinia,
-  GenericStore,
-} from '.'
-
-const useCounter = defineStore({
-  id: 'counter',
-  state: () => ({ n: 0 }),
-})
-
-type CounterStore = ReturnType<typeof useCounter>
-
-const computedStores = mapStores(useCounter)
-
-expectType<{
-  counterStore: () => CounterStore
-}>(computedStores)
+import { expectType, createPinia, GenericStore } from '.'
 
 const pinia = createPinia()