Skip to content

Invalid displayName parsing starting with v2.1.0 #395

@jzempel

Description

@jzempel

After the removal of the parsing filter in #368, the first displayName encountered is selected, whether or not its component is exported. To test, add the following lines to the end of https://github.com/styleguidist/react-docgen-typescript/blob/master/examples/react-styleguidist-example/components/HocComponent.tsx:

Component.displayName = 'DisplayNameError';
HocComponent.displayName = 'DisplayNameSuccess';

Invalid results based on v2.1.0, tested via node -e 'console.log(require("react-docgen-typescript").parse("./ModifiedHocComponent.tsx"))'...

[
  {
    tags: {},
    filePath: './ModifiedHocComponent.tsx',
    description: '',
    displayName: 'DisplayNameError',
    methods: [],
    props: {}
  }
]

Valid results based on v2.0.0, testing the same...

[
  {
    tags: {},
    filePath: './ModifiedHocComponent.tsx',
    description: '',
    displayName: 'hoc',
    methods: [],
    props: {}
  },
  {
    tags: {},
    filePath: './ModifiedHocComponent.tsx',
    description: 'This example shows HocComponent',
    displayName: 'DisplayNameSuccess',
    methods: [],
    props: {
      prop1: [Object],
      prop2: [Object],
      prop3: [Object],
      prop4: [Object]
    }
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions