Skip to content

Commit

Permalink
fix: add default any type to the errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Dec 31, 2023
1 parent 90492cc commit 9d12c12
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/try.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Ok, Err } from "./result";
*
* @returns A `Promise` to a `Result` containing the result of `promise` or the error it may have thrown.
*/
function try$<TResult, TError>(
function try$<TResult, TError = any>( // eslint-disable-line @typescript-eslint/no-explicit-any
promise: Promise<TResult>
): Promise<Result<TResult, TError>> & Dwaitable<Result<TResult, TError>> {
const task = Promise.resolve(promise)
Expand Down
2 changes: 1 addition & 1 deletion src/tryFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type AnyFunction = (...args: any[]) => any;
*
* @returns A `Result` containing the result of `fn` or the error it may have thrown.
*/
function tryFn$<TError, TFunc extends AnyFunction>(
function tryFn$<TFunc extends AnyFunction, TError = any>( // eslint-disable-line @typescript-eslint/no-explicit-any
fn: TFunc,
...args: Parameters<TFunc>
): Result<ReturnType<TFunc>, TError> {
Expand Down
2 changes: 1 addition & 1 deletion tests/try.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("try$ Tests", () => {
});

test("should return a promise which can be turned into a DeferredPromise using dwait function", async () => {
const result = try$<string, unknown>(resolveMock()).dwait().isErr();
const result = try$<string>(resolveMock()).dwait().isErr();
await expect(result).resolves.toEqual(false);
});
});

0 comments on commit 9d12c12

Please sign in to comment.