How to document string literals?

61 views
Skip to first unread message

Vladimir

unread,
Apr 4, 2017, 7:53:10 PM4/4/17
to JSDoc Users
I have a function, which argument can take a certain set of string values.
Here is an example:

const TYPES = {
 
"key-one": 1,
 
"key.two": 2,
 
"keyt<>three": 3
};

function chooseType(t) {
 
return TYPES[t];
}

chooseType
("key-one");

So, the value of "t" parameter should be only one of keys of TYPES object.
Those keys are strings and may contain non-alpabet chars.

So I don't understand, how to correctly make JSDoc to describe it.

I know about enumerating all possible values in jsdoc such way:

/** @param {'key-one'|'key.two'|'keyt<>three'} t */

But it looks disgustingly, and I hope there is right way.



Reply all
Reply to author
Forward
0 new messages