Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type {*} is replaced with {any} #228

Open
shadowspawn opened this issue Mar 1, 2024 · 3 comments
Open

Type {*} is replaced with {any} #228

shadowspawn opened this issue Mar 1, 2024 · 3 comments

Comments

@shadowspawn
Copy link

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
 */
@shadowspawn
Copy link
Author

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

@shadowspawn
Copy link
Author

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.

@sxxov
Copy link
Contributor

sxxov commented Mar 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants