Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to JsDoc a "mixed" type?

Simple question, how do I document that "Mixed-type"? I know I could just list all possible types like {null|undefined|String|Number|Object} and end up finding myself missing one and making it overly complex. I tried using the Mixed keyword, but it popups errors in many IDEs such as WebStorm.

like image 247
Tower Avatar asked Feb 05 '11 19:02

Tower


2 Answers

I found the way to do it:

/**  * @param {*} foo  */ function bar(foo) {} 
like image 196
Tower Avatar answered Oct 11 '22 05:10

Tower


Use {}

There is an example from http://usejsdoc.org/tags-type.html:

An object called 'myObj' with properties 'a' (a number), 'b' (a string) and 'c' (any type).

{{a: number, b: string, c}} myObj // or: {Object} myObj {number} myObj.a {string} myObj.b {} myObj.c 
like image 38
Dmitry Avatar answered Oct 11 '22 03:10

Dmitry