updux/types/index.test-d.ts
2021-10-14 12:30:06 -04:00

28 lines
607 B
TypeScript

import { printType, expectAssignable, expectType } from 'tsd';
import { Updux, ActionGenerator, action } from '.';
const dux = new Updux({});
expectType<unknown>( dux.initial );
() => {
const dux = new Updux<{a: string}>({});
expectAssignable<{initial: {a:string}}>(dux);
}
// 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);
}