[英]Angular parameter types on jsdoc
I'm wondering what are the "proper" parameter types on angular specified stuff within jsdoc? 我想知道jsdoc中指定角度的东西的“适当”参数类型是什么?
Eg. 例如。 if I have something like: 如果我有类似的东西:
/**
* Some comment
*
* @param {WhatHere} $http
* @param {WhatHere} $timeout
*/
function FooBar($http, $timeout) {
}
What are the proper types for those $http and $timeout so that IDE (Web/PhpStorm) can autocomplete those? 那些$ http和$ timeout合适的类型是什么,以便IDE(Web / PhpStorm)可以自动完成这些类型?
Jetbrains products cannot do this by analyzing the code, there's too much magic in Angular's dependency injection system. Jetbrains产品无法通过分析代码来做到这一点,Angular的依赖注入系统中有太多的魔力。 However, you can do it by installing a typed library in at least Webstorm and PyCharm (probably PHPStorm and other Jetbrains products as well): 但是,您可以通过至少在Webstorm和PyCharm中安装类型库来实现(可能还包括PHPStorm和其他Jetbrains产品):
Preferences
> Languages & Frameworks
> JavaScript
> Libraries
转到Preferences
> Languages & Frameworks
> JavaScript
> Libraries
Download…
button 点击Download…
按钮 Typescript community stubs
in the top-left dropdown (don't worry, it also works for JavaScript) 在左上角的下拉列表中选择Typescript community stubs
(不用担心,它也适用于JavaScript) Download and Install
button 找到angular.js,然后单击“ Download and Install
按钮 Manage Scopes…
button and add angular.js to your project by clicking in the second column and selecting angular.js-DefinitelyTyped
. 单击Manage Scopes…
按钮,然后通过在第二列中单击并选择angular.js-DefinitelyTyped
来将angular.js添加到您的项目中。 Now you can annotate your code like this: 现在,您可以像这样注释您的代码:
/**
* @param {$http} $http
* @param {$timeout} $timeout
*/
function FooBar($http, $timeout) {
}
Note that this trick works for all popular libraries that have a TypeScript community stub available! 请注意,此技巧适用于所有具有TypeScript社区存根的流行库!
I will complement Blaise's answer, because lib name has changed, now it is: angularjs-DefinitelyTyped
. 我将补充Blaise的答案,因为lib名称已更改,现在它是: angularjs-DefinitelyTyped
。 Also, have a look angularjs-DefinitelyTyped doc to know which type to specify, example: 另外,请查看angularjs-DefinitelyTyped文档,以了解要指定的类型,例如:
http://joxi.ru/8ZrJ9wDtzMypAj?d=1 http://joxi.ru/8ZrJ9wDtzMypAj?d=1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.