futurGH / ts-to-jsdoc

Transpile TypeScript code to fully compatible JavaScript + JSDoc comments.
MIT License
174 stars 17 forks source link

Missing JSDoc description when it contains @param itself #33

Closed kungfooman closed 6 months ago

kungfooman commented 6 months ago

Hey! I just tried to run ts-to-jsdoc on itself and came across this:

image

(it cuts off the description when encountering @param)

Another case:

image

futurGH commented 6 months ago

Ooh, good catch! The compiler does seem to interpret those as actual JSDoc tags so I'll take that as user error on my part :^)

kungfooman commented 6 months ago

You mean it's a bug in ts-morph? TS compiler handles it correctly in a little test

futurGH commented 6 months ago

Take a look at this. If you select the FunctionDeclaration and run node.jsDoc[0] in your browser console, you'll see that "test" is interpreted as the function's description, while everything following @param is interpreted as documenting the parameter.

In other words, it's not a bug — to the compiler, the function description is just "Generate".

kungfooman commented 6 months ago

Interesting, I only had a quick look at Intellisense before:

image

(it correctly attaches everything as a description only, no description for param)

Seems like it doesn't just rely on the TypeScript AST, at least a certain level of extra code - I couldn't figure out where exactly the extra handling happens :thinking: