jsdocjsdoc3

JSDoc: Promise<Readonly<any>> vs. Promise<Readonly<*>>


I've paid attention that sometimes IDEA/WebStorm offers to use Promise<Readonly<any>> and sometimes Promise<Readonly<*>> when generating a JSDoc.

My questions:

  1. Is there any difference between <any> and <*>?

  2. Which one should I apply in case I want to specify a generic type of object?


Solution

  • According to https://jsdoc.app/tags-type.html (and the Closure Type System it references), * is what indicates that the variable can take on any type. My guess is that you are using VS Code (which can treat JS files as TS, depending on your settings) and it supports Typescript types in JSDoc (and any would be the equivalent of * in Typescript)