Skip to content

Commit

Permalink
fix(types): allow omitting input in executeOnMount when it's undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEdoRan committed Aug 14, 2024
1 parent 6e23887 commit cf8c3a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions packages/next-safe-action/src/hooks.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import type { MaybePromise, Prettify } from "./utils.types";
* Type of base utils object passed to `useAction`, `useOptimisticAction` and `useStateAction` hooks.
*/
export type HookBaseUtils<S extends Schema | undefined> = {
executeOnMount?: {
input: S extends Schema ? InferIn<S> : undefined;
delayMs?: number;
};
executeOnMount?: (undefined extends S
? { input?: undefined }
: {
input: S extends Schema ? InferIn<S> : undefined;
}) & { delayMs?: number };
};

/**
Expand Down
9 changes: 5 additions & 4 deletions website/docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,11 @@ Type of base utils object passed to `useAction`, `useOptimisticAction` and `useS
```typescript
export type HookBaseUtils<S extends Schema | undefined> = {
executeOnMount?: {
input: S extends Schema ? InferIn<S> : undefined;
delayMs?: number;
};
executeOnMount?: (undefined extends S
? { input?: undefined }
: {
input: S extends Schema ? InferIn<S> : undefined;
}) & { delayMs?: number };
};
```
Expand Down

0 comments on commit cf8c3a3

Please sign in to comment.