Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG]: You shouldn't need postgres package for postgres-js #3791

Open
1 task done
jakeleventhal opened this issue Dec 17, 2024 · 2 comments
Open
1 task done

[BUG]: You shouldn't need postgres package for postgres-js #3791

jakeleventhal opened this issue Dec 17, 2024 · 2 comments
Labels
bug Something isn't working priority Will be worked on next

Comments

@jakeleventhal
Copy link

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.38.2

What version of drizzle-kit are you using?

0.30.0

Other packages

No response

Describe the Bug

import { drizzle } from 'drizzle-orm/postgres-js';

const drizzleClient = (datasourceUrl: string | undefined) => {
  const connection = datasourceUrl ?? process.env.DATABASE_URL!;

  const client = () => drizzle({ connection, schema: { ...schema, ...relations } });

  if (!connection) {
    return null as any as ReturnType<typeof client>;
  }

  return client();
};

This code gives me the following error:
Screenshot 2024-12-17 at 9 43 56 AM

This happens if I don't have the postgres package installed. Why should I need to install the postgres package simply for types to work properly for drizzle?

@jakeleventhal jakeleventhal added the bug Something isn't working label Dec 17, 2024
@L-Mario564 L-Mario564 added the priority Will be worked on next label Dec 23, 2024
@Sukairo-02
Copy link
Collaborator

This happens if I don't have the postgres package installed. Why should I need to install the postgres package simply for types to work properly for drizzle?

You need postgres package for types to properly work, because db's $client field gets it's type imported from postgres.
As for the error, I've tried to reproduce it, but failed to get the error you have:
image
Thus, I'm going to need a reproduceable example as well as the exact version of your package manager.

@jakeleventhal
Copy link
Author

{
  "compilerOptions": {
    "allowJs": false,
    "composite": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "incremental": true,
    "inlineSources": true,
    "isolatedModules": true,
    "lib": ["ESNext"],
    "noImplicitOverride": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "tsBuildInfoFile": "${configDir}/dist/.tsbuildinfo",
    "outDir": "${configDir}/dist",
    "resolveJsonModule": true,
    "rootDir": "${configDir}",
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "ES6"
  },
  "exclude": ["${configDir}/dist", "${configDir}/node_modules"]
}
'drizzle-kit': 0.30.0
'drizzle-orm': 0.38.2

As for postgres, it just seems like that ought to be an internal dev dep. Or at least @types/postgres

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working priority Will be worked on next
Projects
None yet
Development

No branches or pull requests

3 participants