Skip to content

Commit

Permalink
fix: Executor cannot return undefined. The only valid result for em…
Browse files Browse the repository at this point in the history
…ptiness is `null`.
  • Loading branch information
alexkvak committed Jun 24, 2020
1 parent e164f04 commit ed8a701
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface ExecutorContext<R> {
record?: Record<R>;
}

type NonUndefined<T> = T extends undefined ? never : T;

export async function runExecutor<R>(executor: Executor<R>): Promise<R> {
const result = await executor();

Expand All @@ -19,4 +21,4 @@ export async function runExecutor<R>(executor: Executor<R>): Promise<R> {
return result;
}

export type Executor<R> = (...args: unknown[]) => Promise<R> | R;
export type Executor<R> = (...args: unknown[]) => Promise<NonUndefined<R>> | NonUndefined<R>;

0 comments on commit ed8a701

Please sign in to comment.