react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

Expose more TypeScript types

Open matyasf opened this issue 2 years ago • 1 comments

We are using react-docgen to parse TypeScript component files and display their props and types in a documentation app. Our issue is that typing our parser code is not possible since these types are not exported. Would it be possible to expose more types? Heres our code: https://github.com/instructure/instructure-ui/blob/56c7c38e3f360b7110a720a7268b770c916e1500/packages/docs/buildScripts/DataTypes.mts#L89C1-L89C1 We'd like that these types are exported at least:

interface MethodParameter 
interface MethodReturn 
interface PropDescriptor 
interface PropTypeDescriptor
type TypeDescriptor
interface SimpleType
interface LiteralType
interface ElementsType
interface FunctionArgumentType
interface FunctionSignatureType
interface TSFunctionSignatureType
interface ObjectSignatureType
interface BaseType

So basically the types used by the Documentation type. Thanks!

matyasf avatar Oct 20 '23 09:10 matyasf

Sorry for the late reply. Yes that would totally be possible, would you be up for creating a PR?

Sidenote: I'm not super happy with the types, because they do not really represent the result 100%, the types are only accurate if all react-docgen handlers are active, as soon as one is not enabled or a custom handler is added the type might not match up anymore. I thought about every handler coming with their own type, but the whole composition in the end I couldn't get to work and is probably slow.

danez avatar Nov 12 '23 19:11 danez

Hi! We also would like this. I made a PR for it #969

christon88 avatar Jan 21 '25 10:01 christon88