From 5d34745abfbe7e90d56f7e10fa0ec997b90878ed Mon Sep 17 00:00:00 2001 From: Dmitry Boldyrev Date: Fri, 15 Dec 2023 00:47:29 +0600 Subject: [PATCH] Add type tests --- test-typings/previous-value.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test-typings/previous-value.ts diff --git a/test-typings/previous-value.ts b/test-typings/previous-value.ts new file mode 100644 index 00000000..987a75d3 --- /dev/null +++ b/test-typings/previous-value.ts @@ -0,0 +1,34 @@ +import { expectType } from 'tsd'; +import { Store, createStore, createEvent } from 'effector'; +import { previousValue } from '../dist/previous-value'; + +{ + const $foo = createStore('a'); + const $fooPrev = previousValue($foo); + + expectType>($fooPrev); +} +{ + const $foo = createStore('a'); + const $fooPrev = previousValue($foo, 'b'); + + expectType>($fooPrev); +} +{ + const $foo = createStore('a'); + const $fooPrev = previousValue($foo, 0); + + expectType>($fooPrev); +} +{ + const $foo = createStore('a'); + const $fooPrev = previousValue($foo, undefined); + + expectType>($fooPrev); +} +{ + const foo = createEvent(); + + // @ts-expect-error + previousValue(foo, 0); +}