as-procedure
Version:
easily create procedures within a pit-of-success
9 lines (8 loc) • 633 B
TypeScript
import { NotNull } from 'type-fns';
type ExpectOutputIsPresent<O extends Record<string, any> | null> = (operation: 'isPresent') => Promise<NotNull<O>>;
type ExpectOutput<O extends Record<string, any> | null> = ExpectOutputIsPresent<O>;
export type WithExpectOutput<TLogic extends (...args: any[]) => Promise<Record<string, any> | null>> = (...args: Parameters<TLogic>) => ReturnType<TLogic> & {
expect: ExpectOutput<Awaited<ReturnType<TLogic>>>;
};
export declare const withExpectOutput: <O extends Record<string, any> | null, TLogic extends (...args: any[]) => Promise<O>>(logic: TLogic) => WithExpectOutput<TLogic>;
export {};