Skip to content

Commit

Permalink
Add type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zerobias authored and sergeysova committed Dec 14, 2023
1 parent a8abce3 commit 5d34745
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test-typings/previous-value.ts
Original file line number Diff line number Diff line change
@@ -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<Store<string | null>>($fooPrev);
}
{
const $foo = createStore('a');
const $fooPrev = previousValue($foo, 'b');

expectType<Store<string>>($fooPrev);
}
{
const $foo = createStore('a');
const $fooPrev = previousValue($foo, 0);

expectType<Store<string | number>>($fooPrev);
}
{
const $foo = createStore('a');
const $fooPrev = previousValue($foo, undefined);

expectType<Store<string | void>>($fooPrev);
}
{
const foo = createEvent();

// @ts-expect-error
previousValue(foo, 0);
}

0 comments on commit 5d34745

Please sign in to comment.