FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]: Many TypeScript Compile Errors (drizzle-orm/neon-http ; Postgres)

Fresh3 days ago
Mar 14, 20260 views
Confidence Score81%
81%

Problem

What version of `drizzle-orm` are you using? ^0.28.6 What version of `drizzle-kit` are you using? ^0.19.13 Describe the Bug During the build step for Typescript, I run into the same "10 errors in 9 files" within the drizzle-orm Node modules package. Reproduced in 3 different projects, one of new was fresh, following the instructions step-by-step for Neon integration over http, as Firebase Cloud Functions do not support Web Sockets (to my knowledge; I could be wrong.) Step 1: [code block] Step 2: Ensure your env contains the string you need and is being read, then - [code block] Step 3: [code block] Build Errors (Same In all Projects Tested): [code block] Expected behavior Expect TypeScript to be able to build. Confirmed errors exist in individual node_module files noted in build process as well Environment & setup Server Platform: Firebase Cloud Functions Node Version: 18 Database Type: Neon.tech PostgreSQL Connection Type: http, ssl TypeScript Version: "^4.9.0" Editor: VSCode

Error Output

error TS2307: Cannot find module 'mysql2/promise' or its corresponding type declarations.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix TypeScript Compile Errors in drizzle-orm Integration

Medium Risk

The TypeScript compile errors are likely caused by missing type declarations for the 'mysql2/promise' module, which is a dependency of drizzle-orm. This can occur if the module is not installed or if the TypeScript configuration does not include the necessary type definitions.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Install mysql2 package

    Ensure that the mysql2 package is installed in your project, as drizzle-orm may depend on it for certain functionalities.

    bash
    npm install mysql2
  2. 2

    Install type declarations for mysql2

    Install the type declarations for mysql2 to resolve the TypeScript errors related to missing types.

    bash
    npm install --save-dev @types/mysql2
  3. 3

    Update tsconfig.json

    Ensure that your tsconfig.json file includes the necessary settings to recognize node modules and type declarations.

    json
    {
      "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "strict": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true
      }
    }
  4. 4

    Rebuild the project

    After making the above changes, rebuild your TypeScript project to ensure that the errors are resolved.

    bash
    npm run build
  5. 5

    Verify the integration

    Run your application to verify that the drizzle-orm integration with Neon is functioning correctly without TypeScript errors.

    bash
    npm start

Validation

Confirm that the TypeScript build completes without errors and that the application runs as expected. Check for any remaining TypeScript errors in the console.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbug