npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-type-doc

v1.3.2

Published

A powerful TypeScript type documentation generator for React components

Downloads

1,186

Readme

react-type-doc

react-type-doc 用于把 TypeScript / React 源码解析成结构化类型文档 JSON,并提供只读运行时与开箱即用的 UI 面板。它解决的问题不是“打印类型字符串”,而是把属性、联合、泛型、循环引用和 $ref 组织成可在应用中稳定浏览的数据。

主要入口

| 子路径 | 作用 | 适用场景 | |--------|------|----------| | react-type-doc | defineConfig、完整解析导出、PropsDocReadernpx react-type-doc CLI | 构建期生成 JSON、Node 侧解析、需要完整类型能力时 | | react-type-doc/runtime | 只读运行时 API,包含 PropsDocReader 及消费 JSON 所需的工具 | 浏览器或前端 bundle 只读取已生成数据时 | | react-type-doc/ui | TypeDocPanelTypeDocEditorPanelTypeDocEditorPanelLazyen / zhCN | 需要直接渲染类型文档界面时 |

安装

npm install react-type-doc

使用方式

  1. 用 CLI 生成 JSON。
npx react-type-doc init
npx react-type-doc
  1. 在运行时读取同一份 JSON。
import typeData from './react-type-doc.json';
import { PropsDocReader } from 'react-type-doc/runtime';
import { TypeDocPanel } from 'react-type-doc/ui';

const reader = PropsDocReader.create(typeData);
  1. 在 UI 中展示目标类型。
<TypeDocPanel typeKey="Button" data={typeData} />

TypeDocEditorPanelTypeDocEditorPanelLazy 适合 CodeMirror 风格的代码面板;TypeDocEditorPanelLazy 可与 Suspense 搭配按需加载,相关运行时依赖会随 react-type-doc 一起安装。

关键注意事项

  • data 必须是 CLI 生成的 JSON;PropsDocReader 和 UI 都只消费生成结果,不直接解析源码。
  • typeKey 必须与 JSON 里的 keys 对齐,否则面板找不到目标类型。
  • PropsDocReader.create(data) 适合多份数据并存;PropsDocReader.getInstance(data) 适合全局共享一份数据。
  • 使用 react-type-doc/ui 时,应用需要自行安装 reactreact-domstyled-components
  • 使用 TypeDocEditorPanel / TypeDocEditorPanelLazy 时,不需要额外安装 CodeMirror 相关依赖;它们会随 react-type-doc 一起提供。
  • 泛型展示依赖结构化元数据 genericParameters。当这份信息存在时,声明头会渲染完整泛型,例如 interface Response<T = unknown, E = Error> {};如果只有旧的 name / text,则回退到兼容显示,不会从实例化结果自动反推原始泛型声明。

文档

许可证

MIT