Skip to content

Commit

Permalink
fix: revert type instance or null to Fail #194
Browse files Browse the repository at this point in the history
  • Loading branch information
4lessandrodev committed Dec 21, 2024
1 parent d3623a3 commit 78b5424
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/core/fail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import Result from "./result";
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with no payload (`null`) and an error state. The `error` and `metaData`
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail(): Result<null, string, {}>;
function Fail(): Result<string, string, {}>;

/**
* @description Creates a `Result` instance representing a failure state.
Expand All @@ -30,10 +30,10 @@ import Result from "./result";
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with no payload (`null`) and an error state. The `error` and `metaData`
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail(): _Result<null, string, {}>;
function Fail(): _Result<string, string, {}>;

/**
* @description Creates a `Result` instance representing a failure state.
Expand All @@ -47,10 +47,10 @@ function Fail(): _Result<null, string, {}>;
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with no payload (`null`) and an error state. The `error` and `metaData`
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail<E, M extends {} = {}>(error: E extends void ? null : E, metaData?: M): Result<null, E extends void ? string : E, M>;
function Fail<E, M extends {} = {}, P = void>(error: E extends void ? null : E, metaData?: M): Result<P, E extends void ? string : E, M>;


/**
Expand All @@ -65,10 +65,10 @@ function Fail(): _Result<null, string, {}>;
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with no payload (`null`) and an error state. The `error` and `metaData`
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail<E, M extends {} = {}>(error: E extends void ? null : E, metaData?: M): _Result<null, E extends void ? string : E, M>;
function Fail<E, M extends {} = {}, P = void>(error: E extends void ? null : E, metaData?: M): _Result<P, E extends void ? string : E, M>;

/**
* @description Creates a `Result` instance representing a failure state.
Expand All @@ -82,10 +82,10 @@ function Fail<E, M extends {} = {}>(error: E extends void ? null : E, metaData?:
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with no payload (`null`) and an error state. The `error` and `metaData`
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail<E = string, M extends {} = {}>(error?: E extends void ? null : E, metaData?: M): _Result<null, E extends void ? string : E, M> {
function Fail<E = string, M extends {} = {}, P = void>(error?: E extends void ? null : E, metaData?: M): _Result<P, E extends void ? string : E, M> {
const _error = (typeof error !== 'undefined' && error !== null) ? error : 'void error. no message!';
return Result.fail(_error as any, metaData);
}
Expand Down

0 comments on commit 78b5424

Please sign in to comment.