我使用webstorm v 10.0.4。我想在webstorm中使用JSDoc来验证所使用的对象属性是否存在一些错误。我希望以下示例显示警告但没有任何反应。
在设置面板中,在编辑器 - >检查中,在Javascript->常规中,当按" jsdoc"
过滤时,会显示3个参数 JsDoc评论匹配功能签名
可能无效的构造函数使用
验证JsDoc / ASDoc
选择其中3个以显示警告
这里我的例子没有显示任何警告:
/**
*
* @typedef {Object} cleanJRef
*
* @property {string} rRefName
* @property {string} rActiveId
* @property {string} rActiveName
* @property {string} rDbId
* @property {string} rDbName
* @property {Object} rActiveElt
*/
//TODO: why this test do not show a warning or error in webstorm?
/** @type {cleanJRef} */
var testCleanJRef = {
rRefName: 1, //should have a warning here
rActiveId: "0",
rActiveName: "Name",
rDbId: "0",
rDbName: "nom",
rActiveElt: "new Object()", //should have a warning here
incorrectProp: "false" //should have a warning here
};
答案 0 :(得分:0)
仅在使用testCleanJRef.rRefName = 1;
等分配时才进行类型检查。请投票通过WEB-19342以获得有关任何进展的通知
答案 1 :(得分:0)
每条错误的线都没有警告,但警告说: “初始化类型{rRefName:number,rActiveId:string ...,incorrectProp:string}不能分配给varialbe类型cleanJRef。”
我不知道为什么我最初没看到它......