No types in comments?
See original GitHub issueI tried the playground, but when I try something like
* @param {number} x - The first input number
it gives
(7,4): The @param block should be followed by a parameter name
(7,11): Expecting a TSDoc tag starting with "{@"
(7,18): The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Type annotations (aka, types as comments) - LogRocket Blog
Recently, a new ECMAScript proposal called type annotations (previously referred to as types as comments) was revealed.
Read more >Comment Types - JavaScript. Flow
These comments allow Flow to work in plain JavaScript files without any additional work. Comment types syntax. There are two primary pieces of...
Read more >Type Comments - Real Python
In this video, I'll show you about type comments. Up to this point, we've been talking about type hints and annotations, which are...
Read more >JSDoc Reference - TypeScript: Documentation
You can reference types with the “@type” tag. The type can be: Primitive, like string or number . Declared in a TypeScript declaration,...
Read more >Where is the syntax for TypeScript comments documented?
Focus on the types (not the content). JSDoc version (notice types in docs): /** * Returns the sum of a and b *...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is normally true.
Nice! Always great to hear progress being made. 😃
The reason I want source-code-agnostic JS/TSDoc is to be very specific about my docs and how they are presented. I’d like comments to be absolute source of truth for my docs, regardless source code (though a case-by-case opt-in feature could be nice).
Unfortunately all JSDoc tools I’ve tried fumble on TS code because they rely on the source (and an associated AST).
What I want to do is the following sort of documentation. Under the assumption that all classes in the project I’m documenting are mixable classes, then most files will look something like this:
AwesomeFeature.ts
The user of
AwesomeFeature
can extend it as a class, or use it as a mixin:CoolFeature
andOtherFeature
work the same way, as classes or mixins.See what I’m trying to do? The mixability of my classes is inherent throughout the project, and I want to document them very simply.
Tools like TypeDoc try to document (infer) too much, and output too much noise. I don’t want machine-generated “docs” for everything that can possibly be found in my source code. I want to make clean simple semantic human-readable docs, and don’t mind the extra manual labor that will be needed to achieve it.
Someone interested in every single type in the code base can just open the source in VS Code.
I’m thinking of a possible approach: make or use a code-agnostic comment extractor, then pass that to
Doctrine
, and go from there with the Doctrine’s JSON output for writing simple custom humanized docs.In TypeScript, types are specified using in the language itself. It doesn’t make sense to declare them in the comment. When people are writing new TypeScript code using TSDoc, it’s a mistake to put types in a comment. The initial implementation of the TSDoc parser is “strict” and reports an error.
But this practice is valid with JSDoc, since it was designed for JavaScript. Because of that, it’s somewhat common to find that notation in legacy TypeScript code. To accommodate this, the plan is to implement a “lax” mode that allows the TSDoc parser to accept these notations. We’d recommend to use “strict” mode for new projects, and “lax” mode for existing projects.
That’s the plan, but the first priority is to finish the strict TSDoc specification. It’s close to being done, but there’s a few major changes that need to get incorporated before the “1.0” release:
We’re making steady progress on these things, but it takes time.