reactjs / reactjs/react-docgen

Interface extends are supported but not the type ampersand syntax

Open
#928 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
5h 7m
Merged PRs (30d)
4

Description

If we use types in Typescript that can be extended with ampersand syntax &, it won't work.

For example, we have a pretty funky type definition like this in our repository:

export type ILinkProps = ITypeAgnosticLinkProps &
  Omit<INextLinkProps, "children"> & {
    /**
     * Disables a link, visually and functionally
     * @default false
     */
    isDisabled?: boolean;
    /**
     * Sets `target="_blank"` and `rel="noreferrer"` explicitly.
     * If props contain `target="_blank"` and `rel="noreferrer"`
     * this will be set to isExternal automatically.
     * _NOTE:_ This is a pure technical flag, if you're looking for a visual
     * representation of an external link, use the `icon` and the `iconPosition` prop.
     */
    isExternal?: boolean;
  };

First it won't work because of the Omit, but if that would be solved (or deleted), it still doesn't work as the & is not recognized as extends.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported TypeScript example, including the Omit utility and ampersand intersections, then trace the type parsing path that handles interface extends. Check existing tests for TypeScript type extraction if available. Done means both intersection syntax and the shown Omit-based definition are recognized without breaking existing interface-extends behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.