【发布时间】:2018-06-15 21:26:00
【问题描述】:
我有一个类和一个函数,该类的实例或类似的 POJO 对象作为参数。
我想用 JSDoc 注释这个函数。
class Test {
constructor(a, b) {
this.a = a;
this.b = b;
}
}
/**
* @param {Test} test
*/
function handleTest(test) {
console.log(test.a, test.b);
}
// Webstorm complains that argument is not of type Test
handleTest({
a: 'this is a'
});
使用@param {Test} test几乎可以工作...但 WebStorm 抱怨 POJO 不能分配给类型 Test。
我可以做一些 JSDoc 技巧来明确Test 的实例和类似Test 的对象都可以吗?
【问题讨论】:
标签: javascript ecmascript-6 webstorm jsdoc