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

Remove propTypes #1068

Merged
merged 8 commits into from
Mar 1, 2021
Merged

Remove propTypes #1068

merged 8 commits into from
Mar 1, 2021

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Feb 23, 2021

Problem

Now that our components are all written in TypeScript, the developer experience benefits of using propTypes no longer outweighs the maintenance cost.

propTypes were helpful because they displayed console errors when a component was passed incorrect props. However, propTypes were hard to maintain, leading to many propTypes that were incorrect and unspecific (i.e. PropTypes.object).

With TypeScript, developers now get errors directly in their editor or at build-time when a component is being used incorrectly. And we can be more confident in these errors because the TypeScript compiler enforces a higher level of type accuracy than our previous propTypes system.

Solution

This PR removes propTypes from every component and removes tests that checked for propTypes.

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2021

🦋 Changeset detected

Latest commit: 2dfc6f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/components Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Feb 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/6XTLWcPSmLP39YaExNwCw2rtEyb2
✅ Preview: https://primer-components-git-cb-remove-prop-types-primer.vercel.app

@colebemis colebemis mentioned this pull request Feb 23, 2021
53 tasks
@vercel vercel bot temporarily deployed to Preview February 24, 2021 16:59 Inactive
@colebemis colebemis marked this pull request as ready for review February 24, 2021 16:59
if (!options.skipSx) {
it('implements the sx prop', () => {
Copy link

@emplums emplums Feb 24, 2021

Choose a reason for hiding this comment

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

Do we have another way to make sure that all components are getting the correct system and sx props? Not sure how I feel about removing this without replacing it with something else 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that we need a better way to test that system props are being correctly applied but I think that could be done in a separate PR. I don't think that these tests were adding that much value because they weren't testing if passing a system prop applied the correct styles.

Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

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

Approved but left one question!

@vercel vercel bot temporarily deployed to Preview March 1, 2021 16:57 Inactive
@vercel vercel bot temporarily deployed to Preview March 1, 2021 17:04 Inactive
@vercel vercel bot temporarily deployed to Preview March 1, 2021 17:07 Inactive
@colebemis colebemis merged commit d738e99 into main Mar 1, 2021
@colebemis colebemis deleted the cb/remove-prop-types branch March 1, 2021 17:18
@github-actions github-actions bot mentioned this pull request Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants