Closed gustavoguichard closed 5 months ago
Often times, especially in tests, we want to construct the Result type and we have to type all the structure. These functions should help with that by allowing us to construct an ErrorResult like so:
Result
// before: const error: ErrorResult = { success: false, errors: [myError], environmentErrors: [], inputErrors: [], } // after: const error: ErrorResult = makeErrorResult({ errors: [MyError] })
or a SuccessResult like so:
// before: const result: SuccessResult = { success: true, data, errors: [], inputErrors: [], environmentErrors: [], } // after: const result: SuccessResult = makeSuccessResult(data)
Often times, especially in tests, we want to construct the
Result
type and we have to type all the structure. These functions should help with that by allowing us to construct an ErrorResult like so:or a SuccessResult like so: