-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module "mysql2" has no exported member "Types" #1938
Comments
Hi @cptpaws, can you check it in version
Now, you can import it from both Just a suggestion in case you use it with ES ModuleTo import the Constants, I recommend you do it as follows: import mysql from 'mysql2';
// or
import * as mysql from 'mysql2';
// then
mysql.Types; When using by this way in an ES Module import { Types } from 'mysql2'; It will print an error like: import { Types } from 'mysql2';
^^^^^
SyntaxError: Named export 'Types' not found. The requested module 'mysql2' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'mysql2';
const { Types } = pkg; As before, it's just a suggestion 🙋🏻♂️ |
After version Some examples:
I'm closing this Issue, but feel free to ask anything 🙋🏻♂️ |
Hello,
Apparently, when using typescript, the
Types
export fromindex.js
is not being resolved. I assume this is because it's missing from theindex.d.ts
file.However, logging out
Types
works as expected, even if it says that it's missing, so a simple@ts-ignore
works as a workaround. Trying to import from the promise API, however, doesn't work, as expected, since theTypes
object is not exported.Is there a reason why the column types couldn't be exported from
mysql2/promise
as well?Thanks a lot!
The text was updated successfully, but these errors were encountered: