Skip to content

Commit

Permalink
refactor(types): less strict callbacks return type (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
LavransBjerkestrand authored Oct 28, 2024
1 parent b15ef8d commit dc120df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/next-safe-action/src/action-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export function actionBuilder<
// Execute middleware chain + action function.
await executeMiddlewareStack();

const callbacksToExecute: MaybePromise<void>[] = [];
const callbacksToExecute: MaybePromise<unknown>[] = [];

// If an internal framework error occurred, throw it, so it will be processed by Next.js.
if (frameworkError) {
Expand Down
8 changes: 4 additions & 4 deletions packages/next-safe-action/src/hooks.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ export type HookCallbacks<
CBAVE,
Data,
> = {
onExecute?: (args: { input: S extends Schema ? InferIn<S> : undefined }) => MaybePromise<void>;
onSuccess?: (args: { data?: Data; input: S extends Schema ? InferIn<S> : undefined }) => MaybePromise<void>;
onExecute?: (args: { input: S extends Schema ? InferIn<S> : undefined }) => MaybePromise<unknown>;
onSuccess?: (args: { data?: Data; input: S extends Schema ? InferIn<S> : undefined }) => MaybePromise<unknown>;
onError?: (args: {
error: Prettify<Omit<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>, "data">>;
input: S extends Schema ? InferIn<S> : undefined;
}) => MaybePromise<void>;
}) => MaybePromise<unknown>;
onSettled?: (args: {
result: Prettify<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
input: S extends Schema ? InferIn<S> : undefined;
}) => MaybePromise<void>;
}) => MaybePromise<unknown>;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/next-safe-action/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ export type SafeActionUtils<
bindArgsParsedInputs: InferArray<BAS>;
hasRedirected: boolean;
hasNotFound: boolean;
}) => MaybePromise<void>;
}) => MaybePromise<unknown>;
onError?: (args: {
error: Prettify<Omit<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>, "data">>;
metadata: MD;
ctx?: Prettify<Ctx>;
clientInput: S extends Schema ? InferIn<S> : undefined;
bindArgsClientInputs: InferInArray<BAS>;
}) => MaybePromise<void>;
}) => MaybePromise<unknown>;
onSettled?: (args: {
result: Prettify<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
metadata: MD;
Expand All @@ -191,7 +191,7 @@ export type SafeActionUtils<
bindArgsClientInputs: InferInArray<BAS>;
hasRedirected: boolean;
hasNotFound: boolean;
}) => MaybePromise<void>;
}) => MaybePromise<unknown>;
};

/**
Expand Down

0 comments on commit dc120df

Please sign in to comment.