Skip to content

Commit

Permalink
Merge pull request #63 from janglad/bug/distributive-action-types
Browse files Browse the repository at this point in the history
make types non distributive
  • Loading branch information
janglad authored Sep 26, 2024
2 parents d23051e + 51dd313 commit 3db9ef6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/ten-beds-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"safe-fn": patch
"safe-fn-react": patch
---

Fix type issues with the hook (related to distribution)
21 changes: 15 additions & 6 deletions packages/safe-fn/src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,23 @@ export type InferActionErrError<T> =
/**
* Converts a `ResultAsync<T,E>` to a `<ActionResult<T,E>`.
*/
export type ResultAsyncToActionResult<T> =
T extends ResultAsync<infer D, infer E> ? ActionResult<D, E> : never;
export type ResultAsyncToActionResult<T> = [T] extends [
ResultAsync<infer D, infer E>,
]
? ActionResult<D, E>
: never;

export type ActionResultToResultAsync<T> =
T extends ActionResult<infer D, infer E> ? ResultAsync<D, E> : never;
export type ActionResultToResultAsync<T> = [T] extends [
ActionResult<infer D, infer E>,
]
? ResultAsync<D, E>
: never;

export type ActionResultToResult<T> =
T extends ActionResult<infer D, infer E> ? Result<D, E> : never;
export type ActionResultToResult<T> = [T] extends [
ActionResult<infer D, infer E>,
]
? Result<D, E>
: never;

/**
* Converts an `ActionResult<T,E>` to a `Result<T,E>`.
Expand Down

0 comments on commit 3db9ef6

Please sign in to comment.