reactjs / reactjs/react-docgen

Confused react type names on Flow and Typescript

Open
#395 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi, I try convert react-docgen props to JSON-schema. But in typescript and flow, we get different names by different ways to program.Just like this. This ReactReactNode makes me so confused. How should i do with it ?

import React, { ReactNode, Component } from 'react';

interface Props {
  content: ReactNode,
  children: React.ReactNode,
}

class TSReactComponent extends Component<Props> {
  render() {
    return (
      <div>hello world</div>
    );
  }
}

export default TSReactComponent;

react-docgen result

{
  "description": "",
  "displayName": "TSReactComponent",
  "methods": [],
  "props": {
    "content": {
      "required": true,
      "flowType": {
        "name": "ReactNode"
      },
      "description": ""
    },
    "children": {
      "required": true,
      "flowType": {
        "name": "ReactReactNode",
        "raw": "React.ReactNode"
      },
      "description": ""
    }
  }
}

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

Reproduce the TypeScript example and inspect the parser path that produces the shown props JSON for ReactNode and React.ReactNode. Compare the Flow and TypeScript results, then verify that the reported type names are handled consistently without regressing the existing output.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
devtools, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.