jsduck
jsduck copied to clipboard
@cfg and @property cannot coexist
I'd like to have a config available also as a property. Seems duck doesn't allow, duck should! :)
/**
* @cfg {String} viewPreset
* @property {String} viewPreset
* A key used to lookup a predefined {@link Sch.preset.ViewPreset} (e.g. 'weekAndDay', 'hourAndDay'), managed by {@link Sch.preset.Manager}. See {@link Sch.preset.Manager} for more information.
*/
viewPreset: 'weekAndDay',
Indeed, having a property with the same name as a config is a perfectly valid case.
Yep. Agree. That's indeed a pretty common case. I'm considering something like:
/**
* @cfgProperty {String} viewPreset
* A key used to lookup a predefined {@link Sch.preset.ViewPreset} (e.g. 'weekAndDay', 'hourAndDay'), managed by {@link Sch.preset.Manager}. See {@link Sch.preset.Manager} for more information.
*/
viewPreset: 'weekAndDay',
+1
Though slightly more verbose, I'd prefer Mats approach of keeping @cfg
and @property
logically separated, but within the same comment block. I use JSDuck more for node than I do Ext these days, and there are times when the cfg type is different from the property - think getters/setters. For example, the cfg may be set as a string, but a get
may return an array. That said, a cfgProperty
would be nice when they're always the same type.
Hmm... I don't really like the @cfgProperty
very much - although I proposed it by myself - as it would be yet another tag, and there are already quite a lot of them.
So, maybe @cfg and @property inside the same doc-comment wouldn't be so bad after all. However I still would like to avoid the duplication, and write the name and type just once:
/**
* @cfg {String} viewPreset
* @property
* A key used to lookup...
*/
viewPreset: 'weekAndDay',
Or actually in this concrete case, they both should be auto-detected:
/**
* @cfg
* @property
* A key used to lookup...
*/
viewPreset: 'weekAndDay',