Effect CommunityEC
Effect Community6mo ago
1 reply
Kairu

Type errors with `@effect/sql-drizzle`

https://github.com/kylekz/effect-drizzle-repro

i'm experimenting with discord bot stuff based on effect-ts/discord-bot and having some type issues using @effect/sql-drizzle

packages/db/src/index.ts has two errors:
when defining the schema passed into Pg.layerWithConfig:
Type 'typeof import("/home/kyle/code/effect-drizzle-repro/packages/db/src/schema")' is not assignable to type 'Record<string, never>'.
  Property 'Servers' is incompatible with index signature.
    Type 'PgTableWithColumns<{ name: "servers"; schema: undefined; columns: { guildId: PgColumn<{ name: "guildId"; tableName: "servers"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; ... 7 more ...; generated: undefined; }, {}, { ...; }>; ... 4 more ...; id: PgColumn<...>; }; d...' is not assignable to type 'never'.ts(2322)

and when exporting the layer:
The inferred type of 'DatabaseLive' cannot be named without a reference to '.bun/@effect+sql@0.44.0+b58dd6837bc1e26a/node_modules/@effect/sql/SqlClient'. This is likely not portable. A type annotation is necessary.ts(2742)


doing Pg.layer instead of Pg.layerWithConfig() resolves that type error, but i'd like to be able to use drizzle's rqb which requires passing the schema in.
at the moment i'm just assuming this is a bun/monorepo issue with types, as it works at runtime
Was this page helpful?