Add new @enum tag
Hi!
Current JSDoc spec allows documenting plain objects as enumerables. This is very helpful when restricting argument types.
An abstract example:
//Season.js
/**
* @enum {String}
*/
const Season = {
SPRING: 'SPRING',
SUMMER: 'SUMMER',
AUTUMN: 'AUTUMN',
WINTER: 'WINTER'
};
export default Season;
//Forecast.js
export default class Forecast {
/**
* @param {Season} season
*/
generate(season) {
//implementation
}
}
//test.js
import Season from './Season.js';
import Forecast from './Forecast.js';
let forecast = new Forecast();
forecast.generate(Season.SUMMER);
Current implementation of ESDoc treats season argument of Forecast#generate as a variable import Season from './Season.js' instead of const Season inside Season.js.
Is it planned to support @enum annotations similar to @typedef?
@raveclassic Hi! Thanks for this proposal.
I think that @enum is good. I will try to support it in future version.
But now I have no time :sweat: Please wait a moment.
Thanks.
Any updates to this?
We use them a lot
Any updates to this?
Hey! Any news about this feature?
@Piroru Just switch to typedoc. TS now is able to process js-files and read jsdoc in them.
@raveclassic thanks, we will try it :)
@Piroru We went even further and rewrote our entire codebase in typescript - it's not that hard ;)
@raveclassic We had an attempt before, I guess we need one more try :D
+1 on this
+1 @enum and @event are two missing tag that will make this tool awesome
We still need this :)
I'm also pretty interested by this feature. Please can you also consider this kind of writing :
static get Eases() {
return {
LINEAR: 'Linear',
ACCELERATE: 'Expo.easeIn',
DECELERATE: 'Expo.easeOut',
SINE: 'Sine.easeInOut',
CIRCULAR: 'Circ.easeInOut',
ELASTIC: 'Elastic',
BOUNCE: 'Bounce',
INERTIA: 'Back.easeOut',
STEPPED: 'Stepped'
}
}
To create an enum embedded in a class. :-)
Any updates on this ?
@raveclassic That sounds like a great idea - would love some tips on how to do this. I was able to get ESDoc up and running super easily but I have been unable to figure out how to do the same with typedoc, it just spits out an empty template page.