drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.34k stars 633 forks source link

[BUG]: Type Error when trying to create a connection to a neon instance #2006

Closed fernandortec closed 3 weeks ago

fernandortec commented 8 months ago

What version of drizzle-orm are you using?

0.30.1

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

When trying to create a connection using Neon, I have a type error in the drizzle() function.

My code:

import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import { env } from "../env";

const connection = neon(env.DATABASE_URL);

export const db = drizzle(connection);

image

Expected behavior

Since I'm following the docs, the code snippet above should throw no errors.

Environment & setup

Node - 20.10.0 Bun - 1.0.30 NextJS - 14.1.3

Drizzle-orm - 0.30.1 Drizzle-kit - 0.20.14 @neondatabase/serverless - 0.9.0

Macbook air M1

fernandortec commented 8 months ago

const connection: NeonQueryFunction<boolean, boolean> = neon(env.DATABASE_URL);

this coded fixed the error, Its a very small TS problem, no big deal, I just think you guys should know about it

MickL commented 7 months ago

Having the same issue, following exactly the drizzle docs but still getting a TypeScript error:

Argument of type NeonQueryFunction<false, false> is not assignable to parameter of type NeonQueryFunction<boolean, boolean>

fernandortec commented 7 months ago

Having the same issue, following exactly the drizzle docs but still getting a TypeScript error:

Argument of type NeonQueryFunction<false, false> is not assignable to parameter of type NeonQueryFunction<boolean, boolean>

Yes, if you follow the exact documentation you'll still get the error, kinda weird no one is talking about it

OliverRC commented 6 months ago

This resolved the error for me. I do think either the docs need to change or a fix should be made. Copy pasting from docs should not result in errors or warnings.

import { neon, type NeonQueryFunction } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";

const sql: NeonQueryFunction<boolean, boolean> = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);

You can close my issue and consolidate it here if you like

L-Mario564 commented 3 weeks ago

Docs received a big update recently. If this issue still persists, feel free to reopen this issue.