[docs] Disallow undefined array members at runtime where they're unexpected #21990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: Refactor to make dynamic props table easier to generate that revealed a bug where
<Hidden only={[undefined]} />
did not warn at runtime.Original goal was to do a big refactor of
typescript-to-proptypes
away from a singlegenerate
function and the "branded-nodes-everywhere" approach (seetypeString
and type-guards).typescript-to-proptypes
will be re-purposed to create an intermediary data structure that is used to build the API docs and propTypes (currently TS -> propTypes -> docs, new: TS -> struct, struct -> propTypes, struct -> docs). The intermediary data structure is intended as a generic API which we want to minify. Branding is unnecessary in most cases (structural typing is sufficient). Using propTypes as a public API also has its drawbacks when it comes to module augmentation. E.g. inButton
we need a custom validator forvariant
(see #21648) but our docs can safely be generated from typescript.The single
generate
function was also hard to reason about. We now have dedicated functions for each structure with a single purpose where before some branches where responsible for Components and union nodes. Checking if a prop is required is a bit more convoluted but I'm confident we can simplify this even more.