Effect CommunityEC
Effect Community2y ago
5 replies
jeish

Issue with schema and effect type preservation

Hi everyone, I'm trying out schema and effect but have run into a problem I can't really figure out how to fix.

I have a simple function that just returns the typeof of a schema. When I import that function to another project the type becomes "Types.Simplify<any>". Do you have any tips on how I can keep the type from the return function?

Im doing something like this

mylib/index.ts
export MyType = typeof MyTypeSchema.type
export async function test(): promise <{ ok: true, value: MyType } | { ok: false} >{
const res = Effect.runPromseExit(myEffect)
 if (res.tag === 'success:) {
return {ok: true, value: res.value}
}
return { ok: false }
}


myproj/index.ts
test.then((res) => if (res.ok) {
    // Here I want res.value to keep types but it is Types.simplify<any>
})
Was this page helpful?