How to document union types in typescript?

905 views Asked by At

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. ([email protected], [email protected], [email protected])

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

1

There are 1 answers

0
Dino On BEST ANSWER

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.