Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Typescript: Component props not parsed with 'call signature' type

Open
#897 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reproducing the .tsx sample in the react-docgen playground with Language set to Typescript, comparing Component1 and Component2. Trace the TypeScript parsing entry point for components assigned a call-signature type; done means Component1 includes the same foo prop metadata as Component2.

Written by the indexing model from the issue text.

Description

typescript

Description

In Typescript, it's possible to type a function using a call signature.

For example, this is valid TS:

interface A {
  foo: string;
}

type FnType = (props: A) => string;

const Fn1: FnType = (props) => props.foo; // valid
const Fn2 = (props: A) => props.foo; // also valid

See example in TS Playground

In the above example, react-docgen generates types for Fn2, but does not generate types for Fn1 which is defined with a call signature type.

Expected Behavior

This code:

// component.tsx
interface A {
  foo: string;
}

type ComponentType = (props: A) => JSX.Element;

const Component1: ComponentType = (props) => <div />; // does not include generated props
const Component2 = (props: A) => <div />; // includes generated props

Produces this output:

[
  {
    "description": "",
    "displayName": "Component1",
    "methods": [],
    "props": {
      "foo": {
        "required": true,
        "tsType": {
          "name": "string"
        },
        "description": ""
      }
    }
  },
  {
    "description": "",
    "displayName": "Component2",
    "methods": [],
    "props": {
      "foo": {
        "required": true,
        "tsType": {
          "name": "string"
        },
        "description": ""
      }
    }
  }
]

Actual Behavior

The same code produces this output:

[
  {
    "description": "",
    "displayName": "Component1",
    "methods": []
  },
  {
    "description": "",
    "displayName": "Component2",
    "methods": [],
    "props": {
      "foo": {
        "required": true,
        "tsType": {
          "name": "string"
        },
        "description": ""
      }
    }
  }
]

Steps to Reproduce

Paste the .tsx sample code from the "Expected Behavior" section in the react-docgen playground with Language set to Typescript.

Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
3h 28m
Merged PRs (30d)
6

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.

More from reactjs/react-docgen

All issues in reactjs/react-docgen

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.