So scheint es, dies der richtige Weg ist alles ohne Vorwarnung zu dokumentieren
/**
* @typedef {number} MyType
**/
/**
* @enum {MyType}
*/
var TYPES = {
TYPE_A: 1,
TYPE_B: 2
}
/**
* @param {MyType} type
*/
function useTypesEnum(type) {
}
Das bedeutet:
- MyType eine Zahl
- TYPEN eine Enumeration ist, die MyType
Werte hält
- Diese Funktion akzeptiert Enums, die MyType-Werte ausgeben
Funktioniert für mich auf intellij 2017.1
Allerdings - dies wird weiterhin zulassen, dass jeder String ohne Warnung an die Funktion übergeben wird.
Wenn Sie die ENUM-Werte bestimmen wollen - so sollte es Fehler auslösen, wenn eine andere Zeichenfolge verwendet wurde, verwenden Sie die Methode beschrieben unter: 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"
*/
Haben Sie versucht? Was ist passiert? – Xotic750
Ja, aber nur in [jsfiddle] (http://jsfiddle.net/#&togetherjs=fI19CN5hhH). Es funktioniert, auch wenn ich "TYPES" für "@ param" verwende. –
Haben Sie das jemals gelöst? –