diff --git a/src/go/mightFail.ts b/src/go/mightFail.ts index 08cf079..bc87c16 100644 --- a/src/go/mightFail.ts +++ b/src/go/mightFail.ts @@ -5,11 +5,11 @@ import { makeProxyHandler } from "../utils/staticMethodsProxy" import { MightFail, MightFailFunction, NotUndefined } from "../utils/utils.type" import { mightFailFunction as standardMightFailFunction } from "../utils/mightFailFunction" -const mightFailFunction: MightFailFunction<"go"> = async function (promise: Promise) { +const mightFailFunction: MightFailFunction<"go"> = async function (promise: T) { const { result, error } = await standardMightFailFunction(promise) return error - ? createEither({ result: undefined, error }, "go") - : createEither({ result, error: undefined }, "go") + ? createEither, "go">({ result: undefined, error }, "go") + : createEither, "go">({ result, error: undefined }, "go") } /** diff --git a/src/utils/createEither.ts b/src/utils/createEither.ts index 07a135c..9a96737 100644 --- a/src/utils/createEither.ts +++ b/src/utils/createEither.ts @@ -5,7 +5,7 @@ import type { Either as GoEither } from "../go/Either" // This is not how we intended the tuple feature to work but this is the only way we could currently get TypeScript to play nice // this really should just be an interator on the either object, but it's much more complicated because of TS. -// All the details are in this PR https://github.com/meech-ward/might-fail/pull/7#issuecomment-2395122593 +// All the details are in this PR https://github.com/might-fail/ts/pull/7#issuecomment-2395122593 // hopefully we can change this with a future version of TS. export const createEither = ( diff --git a/src/utils/mightFailFunction.ts b/src/utils/mightFailFunction.ts index 4065706..d6ab5b9 100644 --- a/src/utils/mightFailFunction.ts +++ b/src/utils/mightFailFunction.ts @@ -4,13 +4,13 @@ import { createEither } from "./createEither" import { MightFailFunction } from "./utils.type" export const mightFailFunction: MightFailFunction<"standard"> = async function ( - promise: Promise -): Promise> { + promise: T +): Promise>> { try { const result = await promise - return createEither({ result, error: undefined }) + return createEither>({ result, error: undefined }) } catch (err) { const error = handleError(err) - return createEither({ error, result: undefined }) + return createEither>({ error, result: undefined }) } -} \ No newline at end of file +}