From 51dd313c6dc3766962b7cbc997da4f0824005371 Mon Sep 17 00:00:00 2001 From: janglad Date: Thu, 26 Sep 2024 22:55:09 +0200 Subject: [PATCH] make types non distributive --- .changeset/ten-beds-exercise.md | 6 ++++++ packages/safe-fn/src/result.ts | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .changeset/ten-beds-exercise.md diff --git a/.changeset/ten-beds-exercise.md b/.changeset/ten-beds-exercise.md new file mode 100644 index 0000000..4fab83a --- /dev/null +++ b/.changeset/ten-beds-exercise.md @@ -0,0 +1,6 @@ +--- +"safe-fn": patch +"safe-fn-react": patch +--- + +Fix type issues with the hook (related to distribution) diff --git a/packages/safe-fn/src/result.ts b/packages/safe-fn/src/result.ts index e00d438..ff3319b 100644 --- a/packages/safe-fn/src/result.ts +++ b/packages/safe-fn/src/result.ts @@ -60,14 +60,23 @@ export type InferActionErrError = /** * Converts a `ResultAsync` to a ``. */ -export type ResultAsyncToActionResult = - T extends ResultAsync ? ActionResult : never; +export type ResultAsyncToActionResult = [T] extends [ + ResultAsync, +] + ? ActionResult + : never; -export type ActionResultToResultAsync = - T extends ActionResult ? ResultAsync : never; +export type ActionResultToResultAsync = [T] extends [ + ActionResult, +] + ? ResultAsync + : never; -export type ActionResultToResult = - T extends ActionResult ? Result : never; +export type ActionResultToResult = [T] extends [ + ActionResult, +] + ? Result + : never; /** * Converts an `ActionResult` to a `Result`.