
Look here.
For the first parameter of the addEventListener function, vscode gives me several inbuilt suggestions
How should I make this available in my javascript function?
It could be using Jsdoc or typescript etc.
You can always see what vscode uses for intellisense by hovering on the addEventListener method or ctrl + click to go to the definition in lib.dom.d.ts file where all definitions are present.
By doing the above you will see that the vscode uses the keys of a class called WindowEventMap.
So your function accepting a event listener name could be
function myFunc(event: keyof WindowEventMap): void {
}
A .d.ts file contains typings for java script code. This is how you get typings like the one in your question and from some packages published to npm.
How is your javascript function used by others?
.d.ts files for your code for you. Or If you are not using typescript for development you will have to create your own declarations. And publish your library with these .d.ts file(s). Refer to DefenitelyTyped project for examples..d.ts files and refer to them in your ts config (Haven't tried this myself).