Skip to content

type error when using mismatching Effect versions #1

@skoshx

Description

@skoshx

Example repro:

import { makeServerActionHandler } from "@useflytrap/next-effect"
import { typeid } from "typeid-js"
import { Effect, Schema } from "effect"

export class InvalidPayloadError extends Schema.TaggedError<InvalidPayloadError>()(
  "InvalidPayloadError",
  {
    success: Schema.Literal(false),
    message: Schema.String,
  },
) {}

export class InternalServerError extends Schema.TaggedError<InternalServerError>()(
  "InternalServerError",
  {
    success: Schema.Literal(false),
    message: Schema.String,
  },
) {}

export const createAction = makeServerActionHandler({
  errors: {
    invalidPayload: () => new InvalidPayloadError({ success: false, message: "Invalid payload." }),
    unexpected: () => new InternalServerError({ success: false, message: "Oops! An unexpected error occurred. Please try again later." }),
  },
  generateRequestId: () => typeid("req").toString(),
})

export const CreateApiKey = Schema.Struct({
  name: Schema.String,
})

export const createApiKey = createAction(CreateApiKey, Effect.gen(function* ({ name }) {
  const apiKey = yield* ApiKey.create({ name: "test" })
  return apiKey
}))

Error:

Argument of type 'typeof String$' is not assignable to parameter of type 'AnyNoContext'.
  Property '[TypeId]' is missing in type 'typeof String$' but required in type 'Schema<any, any, never>'.ts(2345)

Effect Version in consumer repo: "effect": "^3.11.5",
Effect version in this package: "effect": "npm:effect@^3.11.9"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions