hosseinmd/prettier-plugin-jsdoc

Type `{*}` is replaced with `{any}`

Opened this issue · 3 comments

I am using {*} for the "any" type in my JSDoc which I think is the standard usage. This is used in examples on these pages:

prettier-plugin-jsdoc is replacing {*} with {any} which I have not seemed documented or used in examples for JSDoc, although presumably reasonable for TSDoc since a TypeScript type.

/**
- * @param {*} previous
+ * @param {any} previous
 */

Could perhaps conditional the {any} on the tsdoc option?

For interest, I was wondering where the {*} came from.

https://jsdoc.app/tags-type says:

A type expression can include the JSDoc namepath to a symbol (for example, myNamespace.MyClass); a built-in JavaScript type (for example, string); or a combination of these. You can use any Google Closure Compiler type expression, as well as several other formats that are specific to JSDoc.

https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System

Syntax Name Syntax Description
The ALL type * Indicates that the variable can take on any type. However, it is an error to attempt to do operations on a value of this type or access any properties on it. You also cannot assign it to any other type variable without a cast.
The ANY type ? Indicates that the variable can take on any type, and the compiler should not type-check any uses of it.

Interesting, that means {*} would be anagolous to {unknown} instead of {any}.