Running into a ts error here...

Running into a ts error here... wondering if you can help
const db = new Kysely<Database>({
dialect: new D1Dialect({ database: env.voting })
});

export interface User {
userId: string
votes: number;
lastVoted: number;
votes_this_month: number;
};

export interface Database {
voting: User;
}
No overload matches this call.
Overload 1 of 2, '(args: KyselyConfig): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.
The types of 'createAdapter().acquireMigrationLock' are incompatible between these types.
Type '(_db: Kysely<any>, _opt: MigrationLockOptions) => Promise<void>' is not assignable to type '(db: Kysely<any>, options: MigrationLockOptions) => Promise<void>'.
Types of parameters '_db' and 'db' are incompatible.
Type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>' is not assignable to type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/cjs/kysely").Kysely<any>'.
Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'.
Overload 2 of 2, '(args: KyselyProps): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.ts(2769)
const db = new Kysely<Database>({
dialect: new D1Dialect({ database: env.voting })
});

export interface User {
userId: string
votes: number;
lastVoted: number;
votes_this_month: number;
};

export interface Database {
voting: User;
}
No overload matches this call.
Overload 1 of 2, '(args: KyselyConfig): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.
The types of 'createAdapter().acquireMigrationLock' are incompatible between these types.
Type '(_db: Kysely<any>, _opt: MigrationLockOptions) => Promise<void>' is not assignable to type '(db: Kysely<any>, options: MigrationLockOptions) => Promise<void>'.
Types of parameters '_db' and 'db' are incompatible.
Type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>' is not assignable to type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/cjs/kysely").Kysely<any>'.
Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'.
Overload 2 of 2, '(args: KyselyProps): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.ts(2769)
3 Replies
wilhuff
wilhuff4mo ago
I haven't seen that error. Is it possible that you have multiple versions of kysely in your node_modules?
wilhuff
wilhuff4mo ago
FWIW There's an alternative D1 dialect here: https://www.npmjs.com/package/@gawdn/kysely-cloudflare-d1
npm
@gawdn/kysely-cloudflare-d1
Cloudflare D1 bindings for Kysely. Latest version: 1.0.3, last published: a year ago. Start using @gawdn/kysely-cloudflare-d1 in your project by running npm i @gawdn/kysely-cloudflare-d1. There are no other projects in the npm registry using @gawdn/kysely-cloudflare-d1.
gwapes
gwapesOP4mo ago
Let me try that one I nuked the node_modules folder and reinstalled and same thing ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected] Nope that errors too
No overload matches this call.
Overload 1 of 2, '(args: KyselyConfig): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.
The types returned by 'createAdapter()' are incompatible between these types.
Property 'supportsCreateIfNotExists' is missing in type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/@gawdn/kysely-cloudflare-d1/node_modules/kysely/dist/cjs/dialect/dialect-adapter").DialectAdapter' but required in type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution-mode": "import" } }).DialectAdapter'.
Overload 2 of 2, '(args: KyselyProps): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.ts(2769)
dialect-adapter.d.ts(18, 14): 'supportsCreateIfNotExists' is declared here.
kysely.d.ts(399, 14): The expected type comes from property 'dialect' which is declared here on type 'KyselyConfig'
kysely.d.ts(395, 14): The expected type comes from property 'dialect' which is declared here on type 'KyselyProps'
No overload matches this call.
Overload 1 of 2, '(args: KyselyConfig): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.
The types returned by 'createAdapter()' are incompatible between these types.
Property 'supportsCreateIfNotExists' is missing in type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/@gawdn/kysely-cloudflare-d1/node_modules/kysely/dist/cjs/dialect/dialect-adapter").DialectAdapter' but required in type 'import("c:/Users/kyebm/OneDrive/Desktop/Desktop (1)/cf bot/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution-mode": "import" } }).DialectAdapter'.
Overload 2 of 2, '(args: KyselyProps): Kysely<Database>', gave the following error.
Type 'D1Dialect' is not assignable to type 'Dialect'.ts(2769)
dialect-adapter.d.ts(18, 14): 'supportsCreateIfNotExists' is declared here.
kysely.d.ts(399, 14): The expected type comes from property 'dialect' which is declared here on type 'KyselyConfig'
kysely.d.ts(395, 14): The expected type comes from property 'dialect' which is declared here on type 'KyselyProps'
maybe im missing some types If you use this what versions are you using? I gave up (lol)
Want results from more Discord servers?
Add your server