From: Eduardo San Martin Morote Date: Thu, 22 Jul 2021 15:23:40 +0000 (+0200) Subject: test: add more test X-Git-Tag: v2.0.0-rc.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0da2099a587435130e4e3be12e9dd3e798918868;p=thirdparty%2Fvuejs%2Fpinia.git test: add more test --- 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