Skip to content

Unable to process props of a component when using synthetic default export in the target component file #102

Closed
@amacleay

Description

@amacleay

Setup:

  • Create a project using allowSyntheticDefaultImports
  • Create a component file in that project which imports React using a synthetic default import: import React from 'react'; and add a component which extends React.Component
  • Run react-docgen-typescript on this file

Expected behavior:
Props are successfully processed

Actual behavior:
No props are reported as existing on the component

FWIW, I don't actually know if this is an issue with this project. It seems to be a complex interaction of the typescript parser and this project which results in this behavior. I have been stepping through extractPropsFromTypeIfStatefulComponent and, in the failing case, instanceType.getProperty('props') returns null, but instanceType.getProperty('prop1') (or whatever an individual prop is called) returns the expected type for that individual property.

I'm happy to help in any way to figure this out, but I'm a bit stumped at the moment. Thanks!

I added a PR just to demonstrate this issue: #101

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