Skip to content

Fix inconsistent type definition in example #43

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

Closed
glasmasin opened this issue Oct 9, 2013 · 1 comment
Closed

Fix inconsistent type definition in example #43

glasmasin opened this issue Oct 9, 2013 · 1 comment

Comments

@glasmasin
Copy link

The documentation for "@type" (http://usejsdoc.org/tags-type.html) implies that curly braces are required.

The referenced Google Closure Compiler type specifications state:

A type expression consists of curly braces ("{ }") containing some combination of the type operators described below.

However there is one example on the "@type" page in which the curly braces are not used (see third line):

/** @type {(string|Array.<string>)} */
var foo;
/** @type number */
var bar = 1;

This is inconsistent and has led to some confusion. I got here while researching this question on stack overflow: http://stackoverflow.com/questions/19237372/what-are-jsdoc-type-curly-braces-for/

Could the docs please be updated to explain cases where {} are not required or could the example be fixed?

Thanks

hegemonic added a commit that referenced this issue Oct 9, 2013
@hegemonic
Copy link
Contributor

The curly braces are "required" around the @type tag's value in the sense that it's always a good idea to use them. If you omit the curly braces in this case, JSDoc will be forgiving and try to parse your type expression anyhow. But the best practice is to use curly braces.

Updated the example to use curly braces.

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