简体   繁体   English

如何记录 typescript 中的联合类型?

[英]How to document union types in typescript?

How to document Union type in typescript so typedoc can pull/show relevant info?如何在 typescript 中记录联合类型,以便typedoc可以提取/显示相关信息? This below is a JSDoc reference but is there one for TSDoc?下面是一份 JSDoc 参考资料,但是否有 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 ) ( 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?编辑:有什么方法可以使用上面的工具为这些类型生成文档?

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.看起来不管我们放什么评论,DocFx 都无法为类型别名和函数生成页面,而只能为类、接口等生成页面……至少在指定的版本中。

I have confirmed this by inspecting the generated *.json output file and the resulting *.yml files.我通过检查生成的*.json output 文件和生成的*.yml文件确认了这一点。 All mentioned files include the metadata but the docfx doesn't generate the html pages for them the right way.所有提到的文件都包含元数据,但 docfx 不会以正确的方式为它们生成 html 页面。

Now I'm using only typedoc with typedoc-plugin-markdown to generate docs and its working fine in its own capacity.现在我只使用带有typedoc typedoc-plugin-markdown的 typedoc 来生成文档,并且它以自己的能力正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM