Skip to content

Commit d48f72c

Browse files
committed
fix[attempt]: add default type for error
1 parent f61462f commit d48f72c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

attempt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export type Result<T, E> = Success<T> | Failure<E>;
1616
* console.log(attempt(() => { throw "err" })); // ["err", undefined]
1717
* ```
1818
*/
19-
export function attempt<T, E>(fn: () => T): Result<T, E> {
19+
export function attempt<T, E = unknown>(fn: () => T): Result<T, E> {
2020
try {
2121
return [undefined, fn()];
2222
} catch (e) {
23-
return [e, undefined];
23+
return [e as E, undefined];
2424
}
2525
}

0 commit comments

Comments
 (0)