kysely-org / kysely-postgres-js

Kysely dialect for PostgreSQL using the Postgres.js client.
MIT License
58 stars 3 forks source link

Should use PostgresJS driver type #66

Open Sleepful opened 1 week ago

Sleepful commented 1 week ago

https://github.com/kysely-org/kysely-postgres-js/blob/30fd3443ebfb47b9dcbf9abb8a81addfea121f9e/src/types.ts#L3

this is using Sql from the npm postgres package: https://github.com/kysely-org/kysely-postgres-js/blob/main/package.json#L39

it should instead use Sql from the postgresJS package: https://github.com/porsager/postgres/blob/master/types/index.d.ts#L660C19-L660C56

Currently I am getting a type error because it tells me that my postgresConnection = postgres(...) is not allowed:

import { PostgresJSDialect, PostgresJSDialectConfig } from "kysely-postgres-js";

const databaseConfig: PostgresJSDialectConfig = {
  postgres: postgresConnection, // gives me TS error
};

You can see here that it is getting the TYPE from the NPMJS registry for POSTGRES, instead of using POSGRESJS driver

Type 'import("https://deno.land/x/postgresjs@v3.4.3/types/index").Sql<{}>' is not assignable to type 'import("file:///Users/jose/Library/Caches/deno/npm/registry.npmjs.org/postgres/3.4.4/types/index").Sql<{}>'. Types of property 'types' are incompatible. Type '(<T>(value: T, oid: number) => import("https://deno.land/x/postgresjs@v3.4.3/types/index").Parameter<T>) & {}' is not assignable to type '(<T>(value: T, oid: number) => import("file:///Users/jose/Library/Caches/deno/npm/registry.npmjs.org/postgres/3.4.4/types/index").Parameter<T>) & {}'. Type '(<T>(value: T, oid: number) => Parameter<T>) & {}' is not assignable to type '<T>(value: T, oid: number) => Parameter<T>'. Property '[PRIVATE]' is missing in type 'import("https://deno.land/x/postgresjs@v3.4.3/types/index").Parameter<T>' but required in type 'import("file:///Users/jose/Library/Caches/deno/npm/registry.npmjs.org/postgres/3.4.4/types/index").Parameter<T>'.
igalklebanov commented 1 week ago

Hey 👋

I'll need a reproduction repo.

Sleepful commented 1 week ago

Good point, I will get back to you later!