Skip to content

Add example : how to extract Props / State interface from react component using compiler API #65

@stepancar

Description

@stepancar

Hello.
I have this sources

import * as React from 'react';

export interface MyComponentProps{
    prop1: number;
    prop2: string;
}
/**
* descriptions for component
*/
export  class MyComponent extends React.Component<MyComponentProps,{}>{
   render(){
     return(
       <div>
       </div>
     );
   }
}

I use docgen from this wiki example

this is output

[
    {
        "name": "MyComponent",
        "documentation": "descriptions for component",
        "type": "typeof MyComponent",
        "constructors": [
            {
                "paramters": [],
                "returnType": "MyComponent",
                "documentation": ""
            }
        ]
    }
]

I want to extend this output by type of first generic passed to react.component.

How to extract generic type passed to parent class?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions