Skip to content

Preserve keyof T expressions instead of eagerly expanding them #76

@dav-is

Description

@dav-is

Problem

When a type includes keyof T (e.g., keyof React.JSX.IntrinsicElements), the extractor eagerly resolves it into the full union of string literals. For IntrinsicElements, this produces 200+ members:

'symbol' | 'object' | 'a' | 'abbr' | 'address' | 'area' | 'article' | 'aside' | 'audio' | 'b' | 'base' | ...

This makes the extracted type data very large and hard to read in documentation.

Example

Source:

interface Parameters {
  defaultTagName?: keyof React.JSX.IntrinsicElements;
}

Current output (simplified): a UnionNode with 200+ literal members and no typeName.

Expected: ideally preserve keyof React.JSX.IntrinsicElements as a recognizable type reference (e.g., via typeName or a dedicated keyof node kind), so downstream consumers can decide whether to expand or display the compact form.

Context

This came up while generating API documentation for Base UI's useRender hook. The defaultTagName property's type gets fully expanded in the docs, producing hundreds of lines of string literal union members. Downstream tools have no way to detect that this was originally a keyof expression and collapse it back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions