-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add capability of transforming and emitting JSDoc comments #17146
Comments
I think we've found a way around it by using |
I'm re-opening this as I would like to know if someone of the TypeScript team would accept pull requests for this feature. I've tried implementing it as a third-party module, but I need access to some private functions and currently it's not doable because JSDoc comments are not emitted (as far as I can see). I'm guessing this would require refactoring the I also created a branch with a small example demonstrating how the explicit return type of a function could be added as a JSDoc comment. |
We are discussing what changes we could make to comment emit to allow this. We already scan comments and often parse JSDoc comments for nodes. One option we are considering is reifying all comments in the compiler and storing them on This would go a long way to simplifying comment emit in the emitter, but we need to balance this against the additional memory overhead associated with storing comment ranges for all nodes. |
@sandersn didn't you change our APIs recently to happen to fulfill this request? |
@rbuckton |
@samvv hi ,I am currently doing generate a ts code using JSON , I hope I can add jsdoc to ast node .but ts not support similar addSyntheticLeadingComment method, Do you have any good ideas here? |
@liyikun Hmmm, been a while since I played with this. Unfortunately, I don't know how to create a synthetic node in the current version of TypeScript. I only know of https://github.com/microsoft/tsdoc, which covers my use-case. |
Hmm sorry but it is no longer exists anymore. So how can I transform a JSDoc comment now? |
it's possible to emit jsdoc nodes using https://gist.github.com/alanhoff/b1a2ed871cf7046ca1f2f3c9e0bae1aa |
Is this new as of TS 4? And are there any issues with transform? |
Any news on how to use JSDoc comments with the factory? Parsing seems to work very well, But I have seen no way of attaching a So is there any way to use JSDoc* nodes? |
Looking at the emitter source the JSDoc* stuff is emitted but the jsDoc field of the nodes not traversed (just what it seems at a first look). Assigning the
// print astWithDoc |
|
I found this issue as a follow up on #41486. I tried to create a custom transformer to rewrite my JSDocs. It might not be a nice But I face a significant problem: there is no I will try to open a PR adding a |
So I am trying to create a new documentation generator for TypeScript together with @BurtHarris. Currently it does not do much; I've been mainly tinkering a bit with the compiler API to see what it is capable of. You will be able to find it here when it's finished.
One of the things we thought about was the ability to 'target' JSDoc comments using the type information provided by TypeScript. I've been investigating how to tackle the issue. Ideally, it would use the transformers the compiler API has to offer but of all the functions provided in
factory.ts
, the ones that came closest wereaddSyntheticLeadingComment
,setSyntheticLeadingComments
,setSyntheticTrailingComments
andaddSyntheticTrailingComment
; none of which provide the means to create complete synthetic JSDoc tags and comments.So with this issue I'm actually asking the status-quo of this feature. Is it still possible to get this on the roadmap? If so, can I help? If not, is there a possibility of a patch that makes it possible to implement this as a third-party module?
Related issues
Previous attempts
The text was updated successfully, but these errors were encountered: