Journal displays wrong driver (I think)

I've only been using drizzle for a little while and so far it was working great, however when I tried to rebuild my docker container i kept getting some (for me) unexplainable errors. Error: node_modules/drizzle-orm/mysql-core/db.d.ts(1,38): error TS2307: Cannot find module 'mysql2/promise' or its corresponding type declarations. I went and checked where in my project the string 'mysql' was used (maybe I accidentally imported 'drizzle-orm/mysql-core' instead of pg-core'. This wasn't the case and the only file in my project referencing 'mysql' was ./drizzle/meta/_journal.json, it has a first level key 'dialect', which is set to 'mysql'. From what I understand I should NOT alter these files directly since they are generated (right?). There for I checked my 'migrate' command
drizzle-kit generate:pg --config=./drizzle.config.js
drizzle-kit generate:pg --config=./drizzle.config.js
and my drizzle.config.js
import { Config } from "drizzle-kit";

export default {
schema: "./src/db/**/schema.ts",
out: "./drizzle",
driver: 'pg'
}
import { Config } from "drizzle-kit";

export default {
schema: "./src/db/**/schema.ts",
out: "./drizzle",
driver: 'pg'
}
and to apply my migrations I use this import:
import { migrate } from 'drizzle-orm/node-postgres/migrator';
import { migrate } from 'drizzle-orm/node-postgres/migrator';
My questions: - how does the generated dialect end up being 'mysql'? - is this the reason drizzle tries to import 'mysql2/promise'? - is it correct to assume that if I only use postgres, that I do not need the mysql2 packages (or are there some under the hood dependencies)? I hope I have provided enough information for someone to help me out, in any thank you in advance for your reply!
5 Replies
Luxaritas
Luxaritas13mo ago
As far as I know, the actual situation here is that you need to disable skipLibCheck in your tsconfig The drizzle typings, which get automatically pulled in by typescript, contain types for all dialects whether you use them or not Sorry, enable skipLibCheck skipLibCheck is a best practice anyways so that the type checker isn’t doing a bunch of unnecessary work
colbustanut
colbustanut13mo ago
I have it enabled now, but from what I understand it's bad practice to do so. Thank you for the quick response
Luxaritas
Luxaritas13mo ago
Most stock configs enable it It generally helps significantly with performance And in general it’s reasonable to assume the typedefs that get shipped are valid Unless I guess you have an edge case of some incompatible subdependency I imagine it’s also possible that a library will ship typedefs with less strictness than your config allows Ah, didn’t realize though that it does disable typechecking on your own .d.ts files though, if you need to add shim types or such
rphlmr ⚡
rphlmr ⚡13mo ago
Yes, it's all or nothing with skipLibCheck 🥲 If these errors come from 'tsc' (type-checking), you can replace it with this sh script: (Maybe not perfect, but it works well for one of my project) https://gist.github.com/rphlmr/405209fbe96635e05033680af61ed9e6
#!/bin/bash

RED="\e[31m"
ENDCOLOR="\e[0m"

echo "⏳ Checking for type errors..."

# Run tsc and capture the output
TYPE_ERRORS=$(tsc --project ./tsconfig.json 2>&1)

# Clean node_modules related errors because we use skipLibCheck:false
CLEAN_ERRORS=$(echo "$TYPE_ERRORS" | sed -e '/node_modules/,/node_modules/ d')

# Print the cleaned output
if [[ -n $CLEAN_ERRORS ]]; then
printf "${RED}❌ Type errors were found${ENDCOLOR}\n"
echo "$CLEAN_ERRORS"
exit 1
fi

echo "✅ No type errors found"
exit 0
#!/bin/bash

RED="\e[31m"
ENDCOLOR="\e[0m"

echo "⏳ Checking for type errors..."

# Run tsc and capture the output
TYPE_ERRORS=$(tsc --project ./tsconfig.json 2>&1)

# Clean node_modules related errors because we use skipLibCheck:false
CLEAN_ERRORS=$(echo "$TYPE_ERRORS" | sed -e '/node_modules/,/node_modules/ d')

# Print the cleaned output
if [[ -n $CLEAN_ERRORS ]]; then
printf "${RED}❌ Type errors were found${ENDCOLOR}\n"
echo "$CLEAN_ERRORS"
exit 1
fi

echo "✅ No type errors found"
exit 0
colbustanut
colbustanut13mo ago
thank you for sharing the script, I'll just have to cope with skipping libcheck for now. it's not that big of deal again thank you for the reply
Want results from more Discord servers?
Add your server