Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should use PostgresJS driver type #66

Open
Sleepful opened this issue Jun 22, 2024 · 4 comments
Open

Should use PostgresJS driver type #66

Sleepful opened this issue Jun 22, 2024 · 4 comments

Comments

@Sleepful
Copy link

Sleepful commented Jun 22, 2024

export interface PostgresJSDialectConfig {

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>'.
@igalklebanov
Copy link
Member

Hey 👋

I'll need a reproduction repo.

@Sleepful
Copy link
Author

Good point, I will get back to you later!

@Thaigun
Copy link

Thaigun commented Nov 14, 2024

Hi! I run into the same issue when trying to setup Deno + Kysely + Postges. I can make a minimal reproduction if that helps.

@Thaigun
Copy link

Thaigun commented Nov 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants