How to add doc comments for variables returned from a function call?

19 hours ago 1
ARTICLE AD BOX

Suppose I have a function like this:

function useFrobnaticator() { return (stringToFrobnicate: string) => { console.log(stringToFrobnicate.length > 20 ? '(too long)' : stringToFrobnicate); }; }

And later I use it like this:

const frobnicate = useFrobnaticator(); frobnicate('Hello World');

Is there a way to add documentation comments to my useFrobnaticator() function so that the frobnicate() function gets these comments? E.g. when I hover over the frobnicate('Hello World') call in the IDE, I want to see documentation like "Frobnicates the supplied string value, taking string length into account".

I know I can add a @returns TSDoc comment to function useFrobnaticator() {}; but my IDE will only show that comment on the useFrobnaticator() call itself, not on the frobnicate() symbol.

Or is there a way to configure/extend my IDE (PyCharm) to show this doc as described?

Barmar's user avatar

Barmar

789k57 gold badges555 silver badges670 bronze badges

oliver's user avatar

4

Read Entire Article