People who use VS Code for JavaScript (not TypeScript, vanilla JavaScript): how should I write my JSDoc comment block to have neatly formatted doc overlays on hover, with meaningful type annotations, for arrow functions ?

My current workaround is to add Hindley–Milner style signatures at the first documentation line, something like "myFunc :: fooType → barType → bazType", but VS Code can't make sense of it and prepends it with "myFunc: foo: any => bar: any => baz: any".

@tdemin Yes it works fine on the first level, but I can't find a way to get it to work with something like:

const myFunc = foo => bar => doStuff(foo, bar);

Adding params info won't work past the first arrow, I couldn't work around that with returns info either. Past the first arrow VS Code is in the world of "any" whatever I type in the JSDoc block

@jkb@octodon.social what I did on the pics is not great, but it looks like there's not much that can be done with JSDoc

at least you can tell JSDoc that you return a function

Follow

@tdemin Yes, that's the conclusion I've reached after trying several approaches earlier today. JSDoc simply doesn't seem suited for the task, if I want to get VS Code to generate proper hover documentation I have to switch to TypeScript.

Thanks for trying, though

@tdemin More precisely: depending on the workaround you can either have names or types, not both

Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!