如此看来,这是没有任何警告记录一切正确的方式
/**
* @typedef {number} MyType
**/
/**
* @enum {MyType}
*/
var TYPES = {
TYPE_A: 1,
TYPE_B: 2
}
/**
* @param {MyType} type
*/
function useTypesEnum(type) {
}
这意味着:
- 的MyType是一个数字
- 类型是保存的MyType值
枚举
- 此功能接受输出MyType值的枚举
intellij上的我工作2017.1
但是 - 这仍然允许每个字符串传递给该函数没有警告。
如果你想太多指定枚举值 - 因此它应该引发错误,如果用另一个字符串,在使用中描述的方法:https://stackoverflow.com/a/36501659/1068746
/**
* @typedef FieldType
* @property {string} Text "text"
* @property {string} Date "date"
* @property {string} DateTime "datetime"
* @property {string} Number "number"
* @property {string} Currency "currency"
* @property {string} CheckBox "checkbox"
* @property {string} ComboBox "combobox"
* @property {string} Dropdownlist "dropdownlist"
* @property {string} Label "label"
* @property {string} TextArea "textarea"
* @property {string} JsonEditor "jsoneditor"
* @property {string} NoteEditor "noteeditor"
* @property {string} ScriptEditor "scripteditor"
* @property {string} SqlEditor "sqleditor"
*/
你试试?发生了什么? – Xotic750
是的,但仅限于[jsfiddle](http://jsfiddle.net/#&togetherjs=fI19CN5hhH)。它可以工作,如果我使用'TYPESSS'作为'@ param'。 –
你有没有解决过这个问题? –