react-docgen-typescript
react-docgen-typescript copied to clipboard
Props not detected unless "import * as React from 'react'"
The TS interface/type used for a component's props are not picked up unless in the same file all of React is imported via: import * as React from 'react'.
This is a bug that needs addressing - happy to help, point me in the direction.
I stumbled across this here also:
https://github.com/strothj/react-docgen-typescript-loader/issues/10#issuecomment-535510047
Did anyone manage to resolve this issue yet?
In my case changing the export type of the components from default export to named export fixed it.
@olee
Well that's not what I call a solution but a workaround 😅
When React is imported via import React from 'react' this line has an additional member called intrinsicName which comes back as 'error'. The returned ts.Type is also missing the members .symbol and .aliasSymbol. ts.Type.getSymbol also returns undefined.
This lack of a symbol causes getComponentInfo to return an empty object for props because both ts.Type.getCallSignatures and ts.Type.getConstructSignatures return an empty array.
I've never delved into this part of JS/TS so my lack of knowledge is hampering my progress. I would appreciate it if someone could take this info and either run with it or provide me with a poke in the right direction. @hipstersmoothie and @pvasek have touched this area most recently (though it has been a while). Could either of you help me out?
I'm looking forward to this issue too, I just recently introduce storybook in our project and I don't get the docgen working
There was no activity for a long time. The issue will be closed soon.
Closing this issue as obsolete.