vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 593 forks source link

The annotation function of vue file synchronizes vscode to parse annotations of js/ts files #2807

Open shaobeichen opened 3 years ago

shaobeichen commented 3 years ago

The annotation function of vue file synchronizes vscode to parse annotations of js/ts files

At present, vetur's support for vue file comments is not friendly, I hope this function can be optimized

https://user-images.githubusercontent.com/18715564/112264123-6105d300-8cab-11eb-8d9d-62604bf4b54e.mp4

https://user-images.githubusercontent.com/18715564/112264150-682ce100-8cab-11eb-9373-1014f0443d77.mp4

jasonlyu123 commented 3 years ago

This is not hard to implement. Only that typescript language service only generate type comment for .js and .jsx files. So it would look like the comment generated in the ts file.

If anyone is interested in implement it. You can add your implementation before this line https://github.com/vuejs/vetur/blob/88a3bc4bf2d6e00265c4ae2f92915f42cfe5a80b/server/src/modes/script/javascript.ts#L210

And you can reference these files for how to implement it https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/jsDocCompletions.ts

https://github.com/sveltejs/language-tools/blob/master/packages/language-server/src/plugins/typescript/features/getJsDocTemplateCompletion.ts