Skip to content

Commit

Permalink
Handle unions between [] types and any[]
Browse files Browse the repository at this point in the history
  • Loading branch information
diogob committed Apr 5, 2024
1 parent 9a2d6fb commit f14d34f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/composable/composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,21 @@ function catchError<T extends Fn, R>(
const res = await fn(...args)
if (res.success) return success(res.data)
return composable(catcher)(res, ...(args as any))
}) as Composable<(...args: Parameters<T>) => ReturnType<T> | R>
}) as Composable<
(
...args: Parameters<T>
) => ReturnType<T> extends any[]
? R extends never[]
? ReturnType<T>
: ReturnType<T> | R
: ReturnType<T> | R
>
}
// T extends any[]
// ? U extends never[]
// ? DomainFunction<T>
// : DomainFunction<T | U>
// : DomainFunction<T | U>

/**
* Creates a new function that will apply a transformation over a resulting Failure from the given function. When the given function succeeds, its result is returned without changes.
Expand Down

0 comments on commit f14d34f

Please sign in to comment.