/** @param {Array.<MyClass>} myClasses An array of MyClass objects. */
TestClass.protoype.someMethod = function( myClasses ){
myClasses[0].aMethodOnMyClass();
}
Run Code Online (Sandbox Code Playgroud)
这使得像WebStorm这样的IDE中的代码完成实际上提供了正确的类型信息[0]..这适用于Array类型,但是我有自己的集合类型,我也想使用这个功能.问题是我找不到合适的语法(可能因为没有,但是).我希望能够以某种方式宣布我的课程如下:
/**
* @typeparam {T} the type parameter
* @constructor {Test2.<T>}
* */
Test2 = function(){};
/**
* @returns {T} a value of type T, where T is the generic type parameter of Test2
*/
Test2.prototype.getGenericValue = function(){}
Run Code Online (Sandbox Code Playgroud)
这个语法或功能不适用于我的IDE,这里没有列出,所以我想知道这个用例的语法是用于WebStorm还是任何其他JS创作工具.