Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Docgen Typescript errors when using certain Material-ui components #12297

Closed
mlenser opened this issue Aug 28, 2020 · 7 comments
Closed

Comments

@mlenser
Copy link

mlenser commented Aug 28, 2020

Describe the bug
I have a design system based on material ui, using typescript. All stories work except any story including the Card or Radio material ui component. I tried very simple cases that only import those components directly.

When I run start-storybook or build-storybook I get the following:

70% sealing React Docgen Typescript Plugin \node_modules\react-docgen-typescript\lib\parser.js:6
11
                if (symbol_3 && symbol_3.declarations.length) {
                                                      ^

TypeError: Cannot read property 'length' of undefined
    at Parser.getLiteralValueFromPropertyAssignment (\node_modules\react-docgen-typescript\lib\
parser.js:611:55)

To Reproduce
I can create a reproducable package if necessary, but it's a bit of work

Expected behavior
The stories build

Screenshots
image

System:
I tried this on Windows and Mac

Windows:

Environment Info:

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
  Binaries:
    Node: 14.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - \node_modules\.bin\yarn.CMD
    npm: 6.14.6 - \node_modules\.bin\npm.CMD
  Browsers:
    Chrome: 84.0.4147.135
    Edge: Spartan (44.18362.449.0)
  npmPackages:
    @storybook/addon-a11y: 6.0.20 => 6.0.20
    @storybook/addon-actions: 6.0.20 => 6.0.20
    @storybook/addon-backgrounds: 6.0.20 => 6.0.20
    @storybook/addon-centered: 5.3.21 => 5.3.21
    @storybook/addon-knobs: 6.0.20 => 6.0.20
    @storybook/addon-viewport: 6.0.20 => 6.0.20
    @storybook/react: 6.0.20 => 6.0.20
    @storybook/theming: 6.0.20 => 6.0.20

Mac:

Environment Info:

  System:
    OS: macOS Mojave 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 14.5.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /node_modules/.bin/yarn
    npm: 6.14.6 - /node_modules/.bin/npm
  Browsers:
    Chrome: 84.0.4147.135
    Firefox: 69.0.1
    Safari: 12.1.1
  npmPackages:
    @storybook/addon-a11y: 6.0.20 => 6.0.20 
    @storybook/addon-actions: 6.0.20 => 6.0.20 
    @storybook/addon-backgrounds: 6.0.20 => 6.0.20 
    @storybook/addon-centered: 5.3.21 => 5.3.21 
    @storybook/addon-knobs: 6.0.20 => 6.0.20 
    @storybook/addon-viewport: 6.0.20 => 6.0.20 
    @storybook/react: 6.0.20 => 6.0.20 
    @storybook/theming: 6.0.20 => 6.0.20 
@kitety
Copy link

kitety commented Sep 8, 2020

Me too.I hope someone to resolve it.

@shilman
Copy link
Member

shilman commented Sep 8, 2020

@mlenser is this an issue you can file a repro for on the react-docgen-typescript repo? cc @hipstersmoothie

@hipstersmoothie
Copy link
Contributor

I was able to get the docgen to work for the following example

import * as React from 'react';
import Card, { CardProps } from '@material-ui/core/Card';

/**
 * MaterialUICard description
 */
export class MaterialUICard extends React.PureComponent<CardProps, {}> {
  public render() {
    return <Card>Test</Card>;
  }
}

Looking at the error you posted I can't find any code that looks like that. What version of react-docgen-typescript is installed in your project? If I could get a reproduction repo I could probably fix this pretty easily.

@stale
Copy link

stale bot commented Dec 25, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 25, 2020
@stale stale bot removed the inactive label Feb 10, 2021
@mlenser
Copy link
Author

mlenser commented Feb 11, 2021

This is no longer an issue as of a month or two ago so I will close this. Sorry for the delay.

@mlenser mlenser closed this as completed Feb 11, 2021
@hazem3500
Copy link

@mlenser how did you solve it?

@mlenser
Copy link
Author

mlenser commented Jun 6, 2021

@hazem3500 sorry, normally I document why these things are fixed. I believe it was solved by one of our dependency updates that came a few months after I opened this issue.

I suggest updating all your dependencies and hopefully that'll solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants