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

Exclude storybook stories from TypeScript compilation for builds #1441

Merged
merged 3 commits into from
Sep 21, 2021

Conversation

jfuchs
Copy link
Contributor

@jfuchs jfuchs commented Sep 20, 2021

In the course of investigating TypeScript type questions with @colebemis, we noticed that building our typedefs with any Storybook story included would lead to some components gaining a css prop in their typedef. E.g., lib/Button/Button.d.ts would include the line:

      css?: import("@emotion/core").InterpolationWithTheme<any>;

And excluding all stories would give us a build without any css props attached to components. This solution should give us clean type defs in our builds while still allowing typechecking of stories. Some caveats:

  • There is a possibility that some errors will not be caught until running the build script, which isn't part of most people's workflow, from what I can tell. I suspect these will be rare.
  • We still don't know why the optional property became required as it did in the linked bug.
  • This bug might only have surfaced with the intersection of multiple factors, and we're removing only one. There might be some other patterns we should still clean up (wild speculation: incorrect typing around PRC components spreading "rest" props on subcomponents)

Closes #1163

Screenshots

image
😅

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@jfuchs jfuchs requested review from colebemis and a team September 20, 2021 20:14
@changeset-bot
Copy link

changeset-bot bot commented Sep 20, 2021

🦋 Changeset detected

Latest commit: 72be46e

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 Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 51.71 KB (0%)
dist/browser.umd.js 52 KB (0%)

Copy link
Member

@dgreif dgreif left a comment

Choose a reason for hiding this comment

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

Nice fix!

@jfuchs jfuchs merged commit f3f5afb into main Sep 21, 2021
@jfuchs jfuchs deleted the jfuchs/exclude-stories branch September 21, 2021 18:40
@primer-css primer-css mentioned this pull request Sep 21, 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.

v27.0.0 breaks TypeScript typings
2 participants