Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

allow void input commands to be called without passing any param #204

@giogonzo

Description

@giogonzo

As per title, a possible (minor?) type-level enhancement. The following tests don't pass with the current command singature:

declare const cvoidf: () => TaskEither<string, number>;
const voidcmd1 = command(cvoidf);
voidcmd1(); // $ExpectType TaskEither<string, number>
voidcmd1({}); // $ExpectError
const voidcmd2 = command(cvoidf, { a });
voidcmd2(); // $ExpectError
voidcmd2(undefined, { a: 'foo' }); // $ExpectType TaskEither<string, number>

Seems fairly easy to do, at the cost of some more unreadable signatures to maintain. E.g., for the first command overload, the return type would become:

: A extends void
  ? (a?: A, ia?: ProductA<I>) => TaskEither<L | IL, P>
  : (a: A, ia?: ProductA<I>) => TaskEither<L | IL, P>;

I'm not sure about the possible negative impacts, I didn't test on real usages yet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions