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

[docs] Disallow undefined array members at runtime where they're unexpected #21990

Merged
merged 6 commits into from
Jul 30, 2020

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Jul 29, 2020

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 single generate function and the "branded-nodes-everywhere" approach (see typeString 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. in Button we need a custom validator for variant (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.

@eps1lon eps1lon added docs Improvements or additions to the documentation typescript labels Jul 29, 2020
@eps1lon eps1lon marked this pull request as draft July 29, 2020 08:45
@mui-pr-bot
Copy link

mui-pr-bot commented Jul 29, 2020

No bundle size changes comparing abfd06b...534687e

Generated by 🚫 dangerJS against 534687e

@eps1lon eps1lon marked this pull request as ready for review July 30, 2020 08:04
@eps1lon eps1lon merged commit bee49be into mui:next Jul 30, 2020
@eps1lon eps1lon deleted the chore/ttp-refactor branch July 30, 2020 10:24
@oliviertassinari
Copy link
Member

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).

@eps1lon It sounds like a great direction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants