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
and my drizzle.config.js
and to apply my migrations I use this import:
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
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
I have it enabled now, but from what I understand it's bad practice to do so. Thank you for the quick response
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
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
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