Effect CommunityEC
Effect Community2y ago
5 replies
bowzee

Issue with Effectful Messages in Effect-TS Schema

Documentation says that
Messages are not only of type string but can return an Effect so that they can have dependencies (for example, from an internationalization service).

I am trying to use it like this

import { Schema } from '@effect/schema';
import { Effect } from 'effect';

Schema.message(() =>
  Effect.gen(function* () {
    const i18n = yield* I18nContextTag;
    return i18n.t('message');
  }),
);


But got compilation error

Type Effect<string, never, I18nContextTag> is not assignable to type Effect<string, never, never>

Type I18nContextTag is not assignable to type never


I dive into type definition and seems like deps are not supported there

export type MessageAnnotation = (
  issue: ParseIssue
) => string | Effect<string> | {
  readonly message: string | Effect<string>
  readonly override: boolean
}


Is it a bug or am i doing something wrong?
Was this page helpful?