Support JSDoc typedef and property
See original GitHub issueI’d love to use the compiler with JSDoc typedef
and property
annotations.
I know that typedef
can be currently used, but it requires to define an actual JavaScript variable.
e.g.
/**
* @typedef {{
* x:number,
* y:number
* }}
*/
let Point;
According to JSDoc typedef docs it can be named within the annotiation itself => it does not require the let Point;
code.
I know that it is not a big deal. Well, it is a bit, because we use the ESLint to lint our code and unused variables are considered to be an error (I am aware that I can add exception, but it’s annoying).
It would be great if the compiler supported the property annotation too. Again, I know that I can use record-like annotation, but this seems to be a bit more readable.
/**
* @typedef {Object} Point
* @property {!number} x Longitude
* @property {!number} y Latitude
*/
EDIT:
I tried to compile the following typedef
with the rest of my code.
/**
* @typedef {Object} Point
* @property {number} lat
* @property {number} lon
*/
var Point;
and it seems to work. But it is not listed in the Closure annotation docs. Is the property
annotation already supported?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:5 (4 by maintainers)
Top GitHub Comments
@dimvar - is there any chance this could be reconsidered? I agree that multiple annotation styles can be confusing, but the
@typedef
and@property
combo feels like it is clearly better syntax for these reasons:If this style of annotation were supported, it could be the favored style and the legacy style could be removed from the reference documentation to avoid confusion.
The Closure Compiler offers a lot of great functionality. The development experience using it could be improved if it “played well” with other tools - specifically documentation and static analysis tools.
Another vote to reconsider this. It’s getting increasingly hard to justify following closure rules whenever someone googles jsdoc and picks the (cleaner?) syntax of @typedef + @property