Skip to content

[docs-infra] keyof member is duplicated in a union #1818

Closed

Description

@Janpot

A keyof member of a union is not deduped against the other members.

interface Config {
  size: string;
  color: string;
}

interface Props {
  x?: 'size' | keyof Config;
}

x documents as:

'size' | 'size' | 'color'

Expected 'size' | 'color'.

The parser preserves keyof as one node, and formatType turns it into text only after the union has already deduped and ordered its members, so its keys never take part.

Only happens on an inline property. Written as export type X = 'size' | keyof Config the alias name is shown instead, so nothing expands.

Related, same cause: keyof Config & string documents as 'size' | 'color' & string, which reads as 'size' | ('color' & string).

The same bug in externalTypes.ts was fixed in #1817; formatType.ts still has it.

Activity

  1. changed the title [-][docs-infra] Expanded keyof unions are not flattened into the enclosing union[/-] [+][docs-infra] Flatten preserved keyof members into the enclosing union[/+] on Aug 27, 2026
  2. changed the title [-][docs-infra] Flatten preserved keyof members into the enclosing union[/-] [+][docs-infra] keyof member is duplicated in a union[/+] on Aug 27, 2026
  3. Janpot commented on Aug 27, 2026

    @Janpot
    MemberAuthor

    Fixed in #1817 (fa9c8ed). 'size' | keyof Config now documents as 'size' | 'color'.

    The intersection half is left alone — it is pre-existing (a type parameter with a union constraint reaches the same path) and has no known occurrence on a real page.

  4. github-actions commented on Aug 27, 2026

    @github-actions

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

  5. added
    scope: docs-infra
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: docs-infra

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions