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); +}