We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f61462f commit d48f72cCopy full SHA for d48f72c
attempt.ts
@@ -16,10 +16,10 @@ export type Result<T, E> = Success<T> | Failure<E>;
16
* console.log(attempt(() => { throw "err" })); // ["err", undefined]
17
* ```
18
*/
19
-export function attempt<T, E>(fn: () => T): Result<T, E> {
+export function attempt<T, E = unknown>(fn: () => T): Result<T, E> {
20
try {
21
return [undefined, fn()];
22
} catch (e) {
23
- return [e, undefined];
+ return [e as E, undefined];
24
}
25
0 commit comments