node-mysql2
node-mysql2 copied to clipboard
There is an intention to make an official @types for the API?
Nowadays TypeScript is a very popular way to write robust JavaScript, I am an adept of this superset and am in a project that needs to connect to MySQL.
Going straight to the point: 1 - exsite an official @types npm for mysql2, which does not use the old typings? 2 - is there intention of creation?
I found this types https://github.com/types/mysql2, but the npm install is not working properly, so I manually downloaded it and added it to my project.
It would be nice if the command npm i --save-dev @type/mysql2 work
Hi @drachehavoc , yes agree with you, would be good to improve typescript experience with node-mysql2 Would you be able to help with this?
Sure! I will write some d.ts and share with you in next days.
I will be happy to help. ^^
honestly, it would be better to have the typescript definition available as part of mysql2. Quite easy to do: you just need one file '.d.ts' and a config entry in package.json. Of course this implies that the definitions are maintained. However I don't think that the public API is changing that much and therefore, after the initial load, changes should be minimal.
@FredericLatour I'm happy to bundle it with the package and maintain. Do you know any tools that might assist in automatic "typings match what's in the code" check? Can you volunteer to add typings here?
@sidorares Great to hear.
Why not starting from the existing type definition (the one I'm using) available here: https://github.com/types/mysql2 (please note that this is not the DefinetelyTyped repo which make it difficult for people to know it exists). I can see that there was already a discussion on the possibility to include it in the repository.
Best approach if you ask me is that you include the files without waiting for a PR and then if something is missing people can PR to add/correct the definition in the repo.
@drachehavoc Any progress on this? If you have one version, maybe it's a good idea to make a PR first. So that we could improve it.
Here to show support. +1 to this. Currently having to write my own interfaces for simple things.
Came here as well for the typings..
Adding manually the following entry in the package.json worked for me:
{
...
"devDependencies": {
...
"@types/mysql2": "git+https://[email protected]/types/mysql2.git"
}
}
But I agree that it would be better if the command npm i -D @type/mysql2 worked.
thumbs up for making the @types prefix official which can standardize the package name to remove confusion while installing type def like me. There was an issue opened (but now closed) regarding the same matter. It is just so sad that the maintainer did not do anything about it.
in the latest version the tyepscript types are shipped as part of the npm package, so no need for the @types or @type/mysql2 anymore
You can look at typings/mysql for the MySQL2 types and its documentation in documentation/en/TypeScript-Examples.md.