For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/zh/components/util.md.
v0.0.57
  • 简体中文
  • Util

    配置@rockshin/tao-ui

    从组件与公开属性推导 TypeScript 类型,不需要运行时工具。

    GetProps

    获取组件的 props 类型,也支持 Context 值与普通属性对象。

    TSX

    GetProp

    获取某个非空属性的类型;第三个参数 Return 可提取函数属性的返回值。

    TSX
    import type { GetProp } from '@rockshin/tao-ui';
    type SearchProps = { onSearch?: (query: string) => Promise<string[]> };
    type SearchResult = GetProp<SearchProps, 'onSearch', 'Return'>; // Promise<string[]>

    GetRef

    推导组件 ref 指向的公开实例,直接用于 useRef。

    TSX

    按需导入

    import type { GetProps, GetProp, GetRef } from '@rockshin/tao-ui/util';

    这些导出只存在于类型系统,不会增加浏览器运行时代码。