Expose API for getting JSDoc nodes in TypeScript files
See original GitHub issueClosure adds various semantic JSDoc annotations that aren’t currently modeled by TypeScript, such as @export (unrelated to TS export) and @nosideeffects. https://developers.google.com/closure/compiler/docs/js-for-compiler#overview
As part of our tool chain to run TypeScript through Closure we’d like to be able to munge these via the TypeScript API. It appears TypeScript gathers JSDoc comments when parsing JavaScript – is there a good reason to not gather these in TypeScript as well?
Specifically, I believe my suggestion amounts to removing the “if” statement in the below code (though I’m not certain this is the right place) in parser.ts
:
function addJSDocComment<T extends Node>(node: T): T {
if (contextFlags & NodeFlags.JavaScriptFile) {
...all of the code is in here...
}
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:20 (10 by maintainers)
Top Results From Across the Web
JSDoc Reference - TypeScript: Documentation
JSDoc Reference. The list below outlines which constructs are currently supported when using JSDoc annotations to provide type information in JavaScript files.
Read more >How to Document an Express API with Swagger UI and JSDoc
In your Express API's app. js file, add the following code below the list of required modules: // app. js const swaggerJSDoc =...
Read more >Is there any way to use `jsdoc` with `.ts` files? Maybe transpile ...
Although as stated by @Remi TypeDoc is a better fit for TypeScript, I use JSDoc for better jsdoc to markdown conversion (as of...
Read more >express-jsdoc-swagger
exposeApiDocs : false, // Open API JSON Docs endpoint. ... baseDir: __dirname, // Glob pattern to find your jsdoc files (multiple patterns can...
Read more >NodeJS Swagger API Documentation Tutorial ... - YouTube
In this video we'll build an ExpressJS CRUD application and document it using Swagger. We'll use swagger- jsdoc to write the specs and ......
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
It appears that TS maybe now gathers JSDoc always. That is, given a ts.Node you can call getDocumentationComment() on it and it updates the (internal property) node.jsDoc (and does some caching).
However, there’s still no way to get at the parsed JSDoc there. getDocumentationComment() only returns the comment portion of the JSDoc, not the tags. So my request still stands, but now it’s just a request to expose API to retrieve the full JSDoc of a node.
I have not checked every code path but it does appear that Parser.parseSourceFile will call createNodeWithJsDoc for JsDocContainer nodes. Can we just remove the internal comment ?
To save doing
var classDeclaration:ts.ClassDeclaration=getFromSomewhere(); var jsDocs=:ts.JSDoc[]=(classDeclaration as any).jsDoc