Skip to content

Commit ec95a10

Browse files
committedJun 12, 2024··
fix(types): don't allow undefined results for stateful actions
1 parent a9a2c8c commit ec95a10

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed
 

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test:lib": "turbo run test --filter=next-safe-action",
1212
"lint:lib": "turbo run lint --filter=next-safe-action",
1313
"build:lib": "turbo run build --filter=next-safe-action --force",
14-
"deploy:lib": "turbo run deploy --filter=next-safe-action"
14+
"deploy:lib": "turbo run deploy --filter=next-safe-action",
15+
"build:pg": "turbo run build --filter=@apps/playground --force"
1516
},
1617
"author": "Edoardo Ranghieri",
1718
"license": "MIT",

‎packages/next-safe-action/src/hooks.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export type HookSafeActionFn<
5353
Data,
5454
> = (
5555
input: S extends Schema ? InferIn<S> : undefined
56-
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
56+
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data> | undefined>;
5757

5858
/**
5959
* Type of the stateful safe action function passed to hooks. Same as `SafeStateActionFn` except it accepts

‎packages/next-safe-action/src/index.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export type SafeStateActionFn<
6464
prevResult: Prettify<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>,
6565
input: S extends Schema ? InferIn<S> : void,
6666
]
67-
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data> | undefined>;
67+
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
6868

6969
/**
7070
* Type of the result of a middleware function. It extends the result of a safe action with

‎website/docs/types.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type SafeStateActionFn<
8989
prevResult: Prettify<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>,
9090
input: S extends Schema ? InferIn<S> : void,
9191
]
92-
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data> | undefined>;
92+
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
9393
```
9494

9595
### `MiddlewareResult`
@@ -327,7 +327,7 @@ export type HookSafeActionFn<
327327
Data,
328328
> = (
329329
input: S extends Schema ? InferIn<S> : undefined
330-
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data>>;
330+
) => Promise<SafeActionResult<ServerError, S, BAS, CVE, CBAVE, Data> | undefined>;
331331
```
332332
333333
### `HookSafeStateActionFn`

0 commit comments

Comments
 (0)
Please sign in to comment.