Effect CommunityEC
Effect Community•3y ago•
2 replies
amr

Type Error in effect-ts schema.parse method

Hello everyone 👋, I'm new to effect-ts and i'm trying to the schema.parse method, but it's resulting in a type error

import * as S from "@effect/schema/Schema";
import { Effect } from "effect";

const TypeSchema = S.literal("a", "b", "c");

const parseType = S.parse(TypeSchema);

Effect.runSyncExit(parseType("a"));


this should work because they're both returning Effect: like the types below

const parseType: (i: unknown, options?: (ParseOptions | undefined)) => Effect<never, ParseError, "a" | "b" | "c">

export const runSyncExit: <, >(effect: Effect.Effect<never, unknown, unknown>) => Exit<unknown, unknown>

However, i'm getting TS2345: Argument of type 'Effect<never, ParseError, "a" | "b" | "c">' is not assignable to parameter of type 'Effect<never, unknown, unknown>'.   Type 'Effect<never, ParseError, "a" | "b" | "c">' is missing the following properties from type 'Effect<never, unknown, unknown>': [EffectTypeId], [symbol], [symbol]

which means that somehow the Effect returned from S.parse is different from the regular Effect imported from the effect package

here are dependencies everything is on the latest version so I don't think I installed the wrong packages but that's biggest cluprit right now

  "dependencies": {
    "@effect/data": "^0.16.1",
    "@effect/schema": "^0.30.1",
    "effect": "2.0.0-next.19"
  }


any help would be appreciated!
Was this page helpful?