updux/types/index.test-d.ts

28 lines
607 B
TypeScript
Raw Normal View History

2021-10-12 17:11:32 +00:00
import { printType, expectAssignable, expectType } from 'tsd';
2021-10-14 16:30:06 +00:00
import { Updux, ActionGenerator, action } from '.';
2021-10-12 17:11:32 +00:00
const dux = new Updux({});
expectType<unknown>( dux.initial );
() => {
const dux = new Updux<{a: string}>({});
expectAssignable<{initial: {a:string}}>(dux);
}
2021-10-14 16:30:06 +00:00
// ActionGenerator
() => {
let a = action('a');
expectAssignable<{type: string}>(a);
expectAssignable<() => {payload?: unknown}>(a);
let b = action('b', (() => ({})) as unknown as (name: string) => { name: string } );
const c = b("foo");
expectAssignable<{payload: { name: string } }>(c);
}