-
Notifications
You must be signed in to change notification settings - Fork 133
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
[playground] No parsing of TypeScript type information? #115
Comments
The TSDoc playground doesn't include a TypeScript compiler at all. (One of the "features" of the @microsoft/tsdoc library is that it's completely self-contained and doesn't require any other library dependencies. So you can easily use it with other compilers besides TypeScript.) The playground admittedly doesn't make this very obvious however, since:
We should make this more clear, but I wasn't sure what's the best way to do that. Some ideas:
@iclanton FYI |
TSDoc is only concerned with parsing comments. TypeScript provides the type information. Any documentation generator will need to interact with the TypeScript compiler API to iterate through documentable nodes and then parse their comments to TSDoc. Take a look at the advanced demo source to see one way this could look. |
Alternatively, we could actually support full TypeScript source files as input. Maybe the "HTML" tab would dynamically change to render whatever comment your cursor was inside. That's probably a much more involved change, though. ;-) |
Thanks for the replies. I understand the scope of the library better now. I like the suggestions to state the expected input more prominently, both in the source README.md and the playground |
If the playground code sample looked like this:
instead of this:
Would that have been more clear? If we do that, we could also report an error if there is any text after the comment. |
Yeah definitely more clear. Error could reported only if there is a second opening |
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. |
Hmmm... I had not thought of this requirement, where you want to work in TypeScript but accomodate developers who code in plain JavaScript. But if I were doing that, I definitely wouldn't want to ask our devs to write all their type information twice (once in the code, and again in the TypeScript doc comments). Wouldn't it make more sense for the compiler to emit type annotations into the .js files, based on its own type analysis? That would save a lot of human effort. In this case technically the .d.ts files could get TSDoc emitted into them and the .js files could get JSDoc. But obviously we would want to align the two as much as possible... We should open a separate GitHub issue since this question is unrelated to the playground. |
@fastfedo encountered the same confusion in #152 (comment) . He gave a couple suggestions:
|
I'm experimenting with the TSDoc Playground and I can't seem to make it parse TypeScript type information. Here's a sample:
As you can see, the
ParamBlock
s in the AST don't include any type annotations forx
andy
.Thoughts?
The text was updated successfully, but these errors were encountered: