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

Refactor for flow intersection and union Props #97

Closed
wants to merge 1 commit into from

Conversation

palange
Copy link

@palange palange commented Jul 8, 2016

This follows up to the flow support added by @danez

Refactor to resolve, when possible, a list of props
from a flow intersection type and to throw an error
when encountering a Props of union type.

This change addresses a bug found in the flowTypeDocBlockHandler
while a props type that is an IntersectionTypeAnnotation or a
UnionTypeAnnotation.

Union types throw an error, rather than generating misleading documentation.
When given a union type, flow will enforce that props conform to only one of
the union-ed types. The documentation format, which lists a single set of props
can't express this.

Refactor to resolve, when possible, a list of props
from a flow intersection type and to throw an error
when encountering a Props of union type.

This change addresses a bug found in the flowTypeDocBlockHandler
while a props type that is an IntersectionTypeAnnotation or a
UnionTypeAnnotation.

Union types throw an error, rather than generating misleading documentation.
When given a union type, flow will enforce that props conform to only one of
the union-ed types. The documentation format, which lists a single set of props
can't express this.

Fix lint errors
@palange
Copy link
Author

palange commented Jul 18, 2016

Updated commit to fix lint errors

} else if (path.node.type == 'UnionTypeAnnotation') {
// The react-docgen output format does not currently allow
// for the expression of union types
throw new TypeError("react-docgen doesn't support Props of union types");
Copy link
Collaborator

@danez danez Aug 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree now, that generating props from union types is more tricky and a bad idea like it was before, but imho it would be better to just ignore the type instead of throwing an exception. People should not be forced to restructure their code just to get the docs working. If I think of my companies huge codebase, this might break the complete docs even if it's just one component that has an union type.

@danez
Copy link
Collaborator

danez commented Aug 18, 2016

This has been merged with #118.
Thanks a lot.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants