]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: add more test
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 22 Jul 2021 15:23:40 +0000 (17:23 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 22 Jul 2021 15:23:40 +0000 (17:23 +0200)
test-dts/customizations.test-d.ts
test-dts/mapHelpers.test-d.ts

index 4bf4460bdd4d39becce7e831efe85e208c1067fc..0eeb6922da90b98ed9b528c9aec119331fabd094 100644 (file)
@@ -5,7 +5,7 @@ import {
   mapStores,
   ActionsTree,
 } from './'
-import { App } from 'vue'
+import { App, ref, Ref } from 'vue'
 
 declare module '../dist/pinia' {
   export interface MapStoresCustomization {
@@ -15,6 +15,9 @@ declare module '../dist/pinia' {
   export interface PiniaCustomProperties<Id, S, G, A> {
     $actions: Array<keyof A>
     myState: number
+
+    set canBeARef(value: number | Ref<number>)
+    get canBeARef(): number
   }
 
   export interface PiniaCustomStateProperties<S> {
@@ -40,6 +43,13 @@ pinia.use((context) => {
   expectType<number>(context.store.$state.myState)
   expectType<number>(context.store.myState)
 
+  expectType<number>(context.store.canBeARef)
+  // it can be set to both a ref and a number
+  context.store.canBeARef = ref(2)
+  context.store.canBeARef = 3
+  // @ts-expect-error
+  context.store.canBeARef = 'eou'
+
   return {
     $actions: Object.keys(context.options.actions || {}),
   }
index 9fc766096c24699208e7065d5202975befdd3992..df7ecefd0fea3dd96c84d0cd49c27f9e43ad4789 100644 (file)
@@ -51,6 +51,9 @@ expectType<{
   upper: () => string
 }>(mapState(useStore, ['a', 'upper']))
 
+// FIXME: @ts-expect-error
+mapState(useStore, ['a']).nested
+
 expectType<{
   newA: () => 'on' | 'off'
   newUpper: () => string