admin管理员组文章数量:1410725
I'm using JSDoc to document my Javascript functions and add type annotations.
In Visual Studio, I am getting intellisense for these functions, which is great. However, if I use an incorrect type (e.g. an integer for a parameter annotated as a string), I don't see any kind of warning about it anywhere. I have the same problem if I use the wrong number of arguments for a function.
I've looked through all the settings in Tools > Options, but didn't see anything relevant. I also use ReSharper, but didn't see anything in R# options either.
Is there some way to get Visual Studio to show a warning?
I'm using JSDoc to document my Javascript functions and add type annotations.
In Visual Studio, I am getting intellisense for these functions, which is great. However, if I use an incorrect type (e.g. an integer for a parameter annotated as a string), I don't see any kind of warning about it anywhere. I have the same problem if I use the wrong number of arguments for a function.
I've looked through all the settings in Tools > Options, but didn't see anything relevant. I also use ReSharper, but didn't see anything in R# options either.
Is there some way to get Visual Studio to show a warning?
Share edited Sep 25, 2018 at 14:21 Cocowalla asked Sep 25, 2018 at 11:36 CocowallaCocowalla 14.4k6 gold badges75 silver badges116 bronze badges2 Answers
Reset to default 3You can also do that in Visual Studio Code, by going to Preferences > Settings and checking Javascript>Implicit Project Config-checkJs.
This should give you some basic intelliSense and mark type errors with familiar red underline.
I found a link with some answers. There are 2 ways to do this:
- Enable it for all Javascript files by adding a
tsconfig.json
to your project's root directory, with `checkJs: true" - Enable it for specific Javascript files by adding
// @ts-check
at the start of the file
In my case however, I wanted to enable this in Razor files, which have all have a script
tag at the bottom - but it seems type checking is only possible in 'pure' Javascript/Typescript files.
本文标签: javascriptHow to show warning when using functions incorrectly according to JSDocStack Overflow
版权声明:本文标题:javascript - How to show warning when using functions incorrectly according to JSDoc? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745015192a2637795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论