question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSDoc with Composition API doesn't work with PropType format on hover

See original GitHub issue

When using the composition API and defineComponent(), Volar doesn’t seem to pick up the comments when we use the PropType format (that might not be the right term, but example will be below showing what I mean).

We have a number of pure TS file components. These can’t easily be changed to .vue files so we are kind of stuck with them. Some of them don’t even have a template, so I’m not sure if those even could be converted to SFC files.

Anyway, we have props declared like this:

props: {
  /** JSDoc comment that does not get detected. */
  msg: {
    type: String as PropType<string>,
    default: "Some value here."
  }
}

When we use that component in a .vue SFC file and hover over the “msg” prop, it correctly picks up the type but not the comment.

If we use the simple format of just:

props: {
    /** JSDoc comment that does get detected. */
    msg: String
}

Below are two images that show what I am referring to. The comment for “inlineMsg” is detected, but the comment for “msg” is not.

image

image

So, questions: A) Is there anything that can be changed in Volar to work with these? B) Is there another syntax we can use (without going to SFC files for the components in question) that would make the comments be detected?

Bonus points: I tried cloning the volar repo to run inside VSCode so I could set breakpoints and try to figure out if this was something I could help with and provide a pull request, but I wasn’t even able to get the repo to build. After running “pnpm i” and then running “npm run build” I get build errors about things like “ws” not having type definitions. Is there a doc or wiki page or something that describes how to get going in this way?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
johnsoncodehkcommented, May 6, 2022
0reactions
johnsoncodehkcommented, May 28, 2022

Duplicate of #703

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSDoc (better-docs) not showing required propType correctly
It is meant to parse the proptypes and take the information from PropTypes and put them into an array. It does. But shows...
Read more >
Unpopular opinion? I think Vue is heading in the wrong ...
I am using Vue 2 in a very large project and it is suffering immensely from the very issue the composition API is...
Read more >
Using JSDoc to enable intellisense for render props in vscode
vscode still shows prop types as any on hover in all the cases; vscode shows all props as optional while hovdering as well...
Read more >
T282835 Evaluate use of TypeScript in the new Vue ...
In regards to the learning curve, we will work to provide documentation and help to ... no better than JSDoc; Vue's PropTypes already...
Read more >
JSDoc: Class: Text - Fabric.js
Default cursor value used when hovering over this object on canvas ... entered for stroke width. this Property does not work on Text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found