Effect CommunityEC
Effect Community2mo ago
7 replies
danielo515

Issue with Inferred Type in DrizzleDb Service Definition

I tried to define the most simple DrizzleDb service that I could,and I immediately reached this problem:
The inferred type of 'DrizzleClient' cannot be named without a reference to '.pnpm/@effect+sql@0.48.0_@effect+experimental@0.57.4_@effect+platform@0.93.3_effect@3.19.4__e_8e9363951cad9039337909de6d8ec658/node_modules/@effect/sql/SqlClient'. This is likely not portable. A type annotation is necessary.ts(2742)

This happens because the code is in a shared package, but it is as simple as this:
import * as PgDrizzle from "@effect/sql-drizzle/Pg";
import { PgClient } from "@effect/sql-pg";
import { Config, Effect } from "effect";
import * as schema from "./schema.js";

const PgLive = PgClient.layerConfig({
  url: Config.redacted("DATABASE_URL"),
});

export class DrizzleClient extends Effect.Service<DrizzleClient>()(
  "DrizzleClient",
  {
    dependencies: [PgLive],
    effect: Effect.gen(function* () {
      const db = yield* PgDrizzle.make<typeof schema>({
        schema,
      });
      return db;
    }),
  },
) {}
Was this page helpful?