Creating a Type-Safe Effect Version of tiny-invariant in Remix
In Remix, tiny-invariant is frequently used to check if something is null | undefined, so I want to make an Effect version of it. However, it does not quite work, and Typescript does not recognize a variable to be not null afterwards. Do you know how I can solve this problem?
export function invariantEffect(...args: Parameters<typeof invariant>) { return Effect.try(() => invariant(...args)).pipe( Effect.mapError(e => new Error(e.message)) )}
export function invariantEffect(...args: Parameters<typeof invariant>) { return Effect.try(() => invariant(...args)).pipe( Effect.mapError(e => new Error(e.message)) )}