4

How to document Union type in typescript so typedoc can pull/show relevant info? This below is a JSDoc reference but is there one for TSDoc?

Example

/**
 * Search parameters
 * These comments are not picked up, I generate blank page
 */
export type SearchParams = string | string[][] | Record<string, string>;

/**
 * Query parameters
 * These comments are not picked up, I generate blank page 
 */
export type QueryParams = SearchParams | Record<string, string | string[]>;

They are just picked up because of export but no info whatsoever was generated. (docfx@2.56.6, typedoc@0.19.2, type2docfx@0.10.5)

EDIT: Is there any way I can generate docs for these types using the tools above?

Dino
  • 161
  • 1
  • 13
  • What isn't working about this? – Aron Jan 28 '21 at 16:41
  • @Aron Hi, so I got them detected but that is just because of export, their dedicated pages are blank (might as well remove them). I would like to at least show the possible types but that is not generated. – Dino Jan 28 '21 at 16:43
  • TypeScript ignores JSDoc type, because TypeScript is type-based. And it's JSDoc, not TSDoc. – Tomáš Wróbel Jan 29 '21 at 10:32
  • @TomášWróbel Oh I get it so this is a reference from JSDoc... But is there an alternative for TSDoc so Typedoc can pick it up? Or never mind the comments ... is there a way to document this so consumers don't wonder what e.g SearchParams are and the generated link doesn't lead to a blank page? (I'll update the question) – Dino Jan 29 '21 at 13:55
  • No, no, no, why do you use @typedef, if you use it in TypeScript and TS (for example .d.ts file) can work instead of JSDoc, not next to each other – Tomáš Wróbel Jan 29 '21 at 14:33
  • Hmm I'm a little bit confused now.. sorry. So this is inside an index.ts file. Ignore the comments, this is just what I was trying out at that time. The module is a simple wrapper for something with one class and a few supporting types and interfaces. I use docfx/typedoc/type2docfx to generate my docs and everything looks ok but no matter what I try these two types just get empty pages. Can you give an example on how to add more information to them? – Dino Jan 29 '21 at 15:10

1 Answers1

0

It appears that it doesn't matter what comments we put there the DocFx is unable to generate pages for type aliases and functions but only for classes, interfaces, etc ... at least at the specified version.

I have confirmed this by inspecting the generated *.json output file and the resulting *.yml files. All mentioned files include the metadata but the docfx doesn't generate the html pages for them the right way.

Now I'm using only typedoc with typedoc-plugin-markdown to generate docs and its working fine in its own capacity.

Dino
  • 161
  • 1
  • 13