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

Expose more TypeScript types #864

Open
matyasf opened this issue Oct 20, 2023 · 1 comment
Open

Expose more TypeScript types #864

matyasf opened this issue Oct 20, 2023 · 1 comment

Comments

@matyasf
Copy link

matyasf commented Oct 20, 2023

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!

@danez
Copy link
Collaborator

danez commented Nov 12, 2023

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.

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

2 participants