]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(types): add PiniaCustomProperties to stores
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 31 Mar 2021 09:56:44 +0000 (11:56 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 31 Mar 2021 09:56:44 +0000 (11:56 +0200)
__tests__/storePlugins.spec.ts
src/index.ts
src/rootStore.ts
src/types.ts

index fb62ccfa7817ab5aed13daec62ed37097768cc3c..62bb11ee4fbd75d4b883e7942daccbe20ed5bc5d 100644 (file)
@@ -28,6 +28,8 @@ describe('store plugins', () => {
     const store = useStore(pinia)
 
     expect(store.n).toBe(20)
+    // @ts-expect-error: n is a number
+    store.n.notExisting
   })
 
   it('can install plugins before installing pinia', () => {
index 1da0810416f121e077a1c02fa8e1cd522d056b5a..50217f25b4f2f7443c0d296c0948f41fe5216683 100644 (file)
@@ -3,7 +3,6 @@ export {
   createPinia,
   Pinia,
   PiniaStorePlugin,
-  PiniaCustomProperties,
 } from './rootStore'
 export { defineStore } from './store'
 export { PiniaPlugin } from './plugin'
@@ -13,5 +12,8 @@ export {
   StoreWithGetters,
   StoreWithActions,
   StoreWithState,
+  PiniaCustomProperties,
 } from './types'
+
+// TODO: remove in beta
 export { createStore } from './deprecated'
index 438cebd96a23e32e3e9d4281115f591812c324ea..850edbcbc5b0a42e4bf5b894e900af2008535958 100644 (file)
@@ -1,5 +1,10 @@
 import { InjectionKey, ref, Ref } from '@vue/composition-api'
-import { StateTree, StoreWithState, StateDescriptor } from './types'
+import {
+  StateTree,
+  StoreWithState,
+  StateDescriptor,
+  PiniaCustomProperties,
+} from './types'
 import { VueConstructor } from 'vue'
 import type Vue from 'vue'
 
@@ -14,12 +19,6 @@ export const storesMap = new WeakMap<
   Map<string, [StoreWithState<string, StateTree>, StateDescriptor<StateTree>]>
 >()
 
-/**
- * Properties that are added to every store by `pinia.use()`
- */
-// eslint-disable-next-line
-export interface PiniaCustomProperties {}
-
 export const piniaSymbol = (__DEV__
   ? Symbol('pinia')
   : /* istanbul ignore next */
index eb0c342db20054305059cf0668d9c6558422b1ab..7c7af92f55b8cdad020ca6390971a0cda0b721e5 100644 (file)
@@ -109,7 +109,11 @@ export type Store<
   S extends StateTree,
   G,
   A
-> = StoreWithState<Id, S> & S & StoreWithGetters<G> & StoreWithActions<A>
+> = StoreWithState<Id, S> &
+  S &
+  StoreWithGetters<G> &
+  StoreWithActions<A> &
+  PiniaCustomProperties
 
 export type GenericStore = Store<
   string,
@@ -138,3 +142,9 @@ declare global {
     }
   }
 }
+
+/**
+ * Properties that are added to every store by `pinia.use()`
+ */
+// eslint-disable-next-line
+export interface PiniaCustomProperties {}