Effect CommunityEC
Effect Community17mo ago
4 replies
Elliot00

Seeking Help with Type Annotation for Schema Decoding in TypeScript

Hello everyone,

I've encountered a problem with Schema types. The code context is a bit long, so please forgive me for directly sharing the link: https://codeberg.org/Elliot00/docube/src/commit/392ac1a0c56a17e5c5b46f49bb6380e392d89a85/packages/common/src/config.ts#L70

I want to use the appropriate type here, but I'm unable to use code like this:

const decode = (raw: unknown) => Effect.succeed(raw).pipe(
  Effect.andThen(Schema.decodeUnknown(schema)),
  Effect.mapError(e => new DocubeError({ message: e.message }))
)


I've typed
decode
as (raw: unknown) => Effect.Effect<unknown, DocubeError>. The problem seems to be with the final Requirements. I'd like to know how to correctly annotate this type.

Any help or insights would be greatly appreciated. Thank you in advance!
Was this page helpful?