kysely-postgres-js
kysely-postgres-js copied to clipboard
Should use PostgresJS driver type
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/[email protected]/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/[email protected]/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/[email protected]/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>'.
Hey 👋
I'll need a reproduction repo.
Good point, I will get back to you later!
Hi! I run into the same issue when trying to setup Deno + Kysely + Postges. I can make a minimal reproduction if that helps.
Install Deno, clone this repo and run deno check . to see the problem.
https://github.com/Thaigun/kysely-postgres-repro
I tried adding import-map.json but couldn't figure out a working configuration. Everything works though and I could run my migrations, just the type checks fail.
Edit:
If, in deno.json imports I import "postgres": "npm:postgres@^3.4.5" instead of "postgres": "https://deno.land/x/postgresjs/mod.js" I get rid of the type check problem and the little functionality I have so far also works. No idea if that will cause any issues at any point.
@Thaigun Your github repository and the type was successfully recognized in the comments. Thanks! windows10+deno 2.1.4
I have specified nodeModulesDir and lock:false as follows and it still worked fine.
{
"lock": false,
"imports": {
"kysely": "npm:kysely@^0.27.4",
"kysely-postgres-js": "npm:kysely-postgres-js@^2.0.0",
"postgres": "npm:postgres@^3.4.5"
},
"nodeModulesDir": "auto"
}
However, I remain concerned about future upgrades.
The next version will use a locally defined type instead of relying on other packages.
It will be compatible with postgres and Bun's SQL.