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

Wiki's code sample for typedef annotation is wrong #3577

Closed
DerekNonGeneric opened this issue Apr 3, 2020 · 3 comments
Closed

Wiki's code sample for typedef annotation is wrong #3577

DerekNonGeneric opened this issue Apr 3, 2020 · 3 comments

Comments

@DerekNonGeneric
Copy link

The code sample for the @typedef tag provided by the wiki is wrong.

It is currently displaying the following.

/** 
 * @typedef {{
 *            foo:string,
 *            bar:number,
 *            foobar:number|string
 *          }}
 */
var Mytype;

This results in error because there are no parenthesis around the | operands.

I would PR the wiki if it were possible, so instead I've demonstrated my proposed fix elsewhere.

@lauraharker
Copy link
Contributor

Thanks for the report! I added parentheses to the example: https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler/_compare/f933dd1632fbe3d1d0217fbc35d57da07b24f569...139296fdb6608615883ff4b5b99d90b3061fa372.

@DerekNonGeneric
Copy link
Author

@lauraharker, thanks!

Might as well update the one on the Annotating Types page while we're at it.

/** 
 * @typedef {{
 *            foo:string,
 *            bar:number,
 *            foobar:number|string
 *          }}
 */
var Mytype;

/** @param {MyType} bar */
function foo(bar) {}

It has the same problem. :)

@lauraharker
Copy link
Contributor

Nice catch! Thanks, fixed https://github.com/google/closure-compiler/wiki/Annotating-Types too.

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