From 0da2099a587435130e4e3be12e9dd3e798918868 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 22 Jul 2021 17:23:40 +0200 Subject: [PATCH] test: add more test --- test-dts/customizations.test-d.ts | 12 +++++++++++- test-dts/mapHelpers.test-d.ts | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test-dts/customizations.test-d.ts b/test-dts/customizations.test-d.ts index 4bf4460b..0eeb6922 100644 --- a/test-dts/customizations.test-d.ts +++ b/test-dts/customizations.test-d.ts @@ -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 { $actions: Array myState: number + + set canBeARef(value: number | Ref) + get canBeARef(): number } export interface PiniaCustomStateProperties { @@ -40,6 +43,13 @@ pinia.use((context) => { expectType(context.store.$state.myState) expectType(context.store.myState) + expectType(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 || {}), } diff --git a/test-dts/mapHelpers.test-d.ts b/test-dts/mapHelpers.test-d.ts index 9fc76609..df7ecefd 100644 --- a/test-dts/mapHelpers.test-d.ts +++ b/test-dts/mapHelpers.test-d.ts @@ -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 -- 2.47.2