Skip to content
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

types are broken #3086

Open
boost3000 opened this issue Sep 30, 2024 · 1 comment
Open

types are broken #3086

boost3000 opened this issue Sep 30, 2024 · 1 comment

Comments

@boost3000
Copy link

i use mysql2 like this:

require('dotenv').config({path: __dirname + '/.env'});
const mysql = require('mysql2/promise');

module.exports = mysql.createPool({
"host": process.env.DB_HOST,
"user": process.env.DB_USER,
"port": parseInt(process.env.NODE_ENV === 'production' ? process.env.DB_PORT_PROD : process.env.DB_PORT_DEV),
"password": process.env.DB_PASSWORD,
"waitForConnections": process.env.DB_WAIT_FOR_CONNECTIONS === 'true',
"connectionLimit": parseInt(process.env.DB_CONNECTION_LIMIT),
"queueLimit": parseInt(process.env.DB_QUEUE_LIMIT),
"dateStrings": [
"DATE",
"DATETIME"
],
maxPreparedStatements: 100,
jsonStrings: true
});

and require it in another file. type hints are not working at all in phpstorm

@wellwelwel
Copy link
Collaborator

@boost3000, I did a test using PhpStorm and everything worked perfectly:

mysql2-phpstorm

Could you confirm if this error is exclusive to PhpStorm or if it also occurs in other editors?

It might help to know your tsconfig.json configs (if used), the Node.js version and less likely, but make sure you DON'T have @types/mysql2 installed (MySQL2 has its own built-in typings) 🙋🏻‍♂️

Also, to use MySQL2 with TypeScript, you need to install @types/node as a development dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants