I am making a npm library at the moment and was wondering how other people implemented the autocompletion and variable type declarations in VS Code.
For example I can type httpconnection.addListener( and I get a popup that tells me that the first argument is of type event, the second argument is of type function void and so on.
This also works for functions that need to be passed an object, like mysql.createConnection({});. If I press CTRL + Spacebar, I now know what properties this object has to have and what properties it can have.
I know that JavaScript is dynamically typed and doesn't have fixed type declarations but rather does the conversion at runtime but how do these other people achieve that?
I have tried to add variable types by using the typescript brackets (variable<Object>) and something else I found somewhere (variable?: Object) but both didn't work.
I least want the autocomplete to show people what properties / attributes they must and what properties they can enter and of what type they should be.
How do I achieve that? Can I just convert the JS file to a TS file and publish it on npm without problems?
Thanks in advance!