[playground] No parsing of TypeScript type information?
See original GitHub issueI’m experimenting with the TSDoc Playground and I can’t seem to make it parse TypeScript type information. Here’s a sample:
/**
* Returns the average of two numbers.
*
* @remarks
* This method is part of the {@link core-library#Statistics | Statistics subsystem}.
*
* @param x - The first input number
* @param y - The second input number
* @returns The arithmetic mean of `x` and `y`
*
* @beta
*/
function getAverage(x: number, y: number) {
return (x + y) / 2.0;
}
As you can see, the ParamBlock
s in the AST don’t include any type annotations for x
and y
.
- ParamBlock
- BlockTag
* BlockTag="@param"
* Spacing=" "
* ParamBlock_ParameterName="x"
* Spacing=" "
* ParamBlock_Hyphen="-"
* Spacing=" "
- Section
- Paragraph
- PlainText
* PlainText="The first input number"
- SoftBreak
* SoftBreak="\n"
- ParamBlock
- BlockTag
* BlockTag="@param"
* Spacing=" "
* ParamBlock_ParameterName="y"
* Spacing=" "
* ParamBlock_Hyphen="-"
* Spacing=" "
- Section
- Paragraph
- PlainText
* PlainText="The second input number"
- SoftBreak
* SoftBreak="\n"
Thoughts?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
TS Playground - An online editor for exploring TypeScript and ...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Read more >Typescript doesn't figure out the generic - Stack Overflow
I'm starting to learn about typescript and I tried to make an parser combinator library, at first types and generics where easy, but...
Read more >Linting with Type Information | typescript-eslint
You're using an outdated version of @typescript-eslint/parser . Update to the latest version to see a more informative version of this error message,...
Read more >Typescript's type system - From solving puzzles to ... - YouTube
Typescript has gained a lot of traction with majority of javascript frameworks adopting it and gaining the power of static types.
Read more >Pragmatic uses of Typescript type system 04
TS playground ↗. From the point of view of Javascript, b variable will still contain a number, but Typescript compiler now knows, that...
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
I understand that perhaps parsing the actual TypeScript code is outside of the scope of what TSDoc is trying to accomplish, but it was definitely something I hoped would be included since I first noticed this project gaining some traction.
In the README it says:
However, the fact that my documentation will have zero indication of the type of a parameter means that this could never serve as a replacement for JSDoc for me personally. If I write a library in TypeScript and it is consumed by a JavaScript application, I would like for there to be typings in the documentation, and not require that people are relying on IDE tooling or digging into the package to find types.
The first thing that drew me to this was the idea of it parsing types from the code to save the redundant declarations in the documentation.
Is there a reason why this is excluded from this project? It seems like a gap to not include typing in documentation personally.
@fastfedo encountered the same confusion in https://github.com/Microsoft/tsdoc/issues/152#issuecomment-474026798 . He gave a couple suggestions: