-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix consistency issue in prop types #727
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
Conversation
Here's the style guide's Percy report for this branch: https://percy.io/Shopify/polaris-styleguide/builds/1225951 It found 37 unreviewed changes, somebody would need to go through them. IconsI found a regression with the icon component, that doesn't show a list of all icons anymore (maybe that's something that needs to be fixed on the style guide itself?): The same happens in the banner component props explorer:
|
A lot of those changes don't look like they're related to this PR specifically, but to the 3.2 update. Went through it and didn't see anything that would be specifically related to this PR(the Props Explorer would have changed). |
4dde30c
to
808370b
Compare
At very real risk of a "Ben: go way you're on holiday" (to which I reply "I am bad at disconnecting, thank you for trying not to enable this bad behaviour <3"): Reverting these changes takes us a step away from being able to enable the "import/no-cycle" eslint rule, which I want to enable so that we can confidently say sewing-kit can stop stop rebuilding polaris with a custom env because our default output when compiled for production doesn't work. Strictly speaking I think circular type imports aren't a problem for SK - only component imports - but the no-cycle rule does not distinguish between them. I'm good with merging this in as an interim measure to get the styleguide up and running with v3.2, but I think the long-term fix is making our type doc tooling in polaris-styleguide be smart enough to handle the valid typescript that gets thrown at it, instead of limiting how we write code in polaris-react - I had no idea this would break things when I refactored and I don't think other people should need to know that there is a limitation either. |
Hey Ben. The first time I worded my comment playfully that you're not supposed to be here but it seems you didn't take it seriously. You're a senior member of the team, who might become a lead in the near future. This kind of behaviour is unacceptable. Think about the example you're setting for everyone else. About the impact you're having on the culture of the team. Not only the team but also the rest of Shopify. It's not ok to acknowledge that you're doing something wrong and keep doing it. This is not an emergency. You're not the only person with context on this. You weren't even pinged on this! Trust that we're taking good care of the codebases when you leave. Of course this is a less than ideal solution. Of course we're looking into fixing this on the script side, so that we can get to a point where all valid TS is accepted. Trust us. We're not stupid. We can get around to it and discuss it with you after you come back from vacation. |
…Explorer These errors were happening because the explorer makes the assumption that all components export a "Props" interface that is then used by the component as the type of its props. When this is not the case, the typedoc output changes format, and the props explorer can't handle this and just silently fails.
808370b
to
10eeb91
Compare
Built this for the styleguide, no issues found, everything working as expected |
Can you add a changelog entry? I'm going to give this a check in web |
@danrosenthal just did! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tophatted in polaris-styleguide.
I got some type errors when tophatting in web, but they seemed to be due to the polaris-tokens bump rather than anything in this PR
@BPScott can you share the errors you got here? |
[dealt with in Slack] |
WHY are these changes introduced?
tl;dr: The Props Explorer type parsing script makes assumptions about the format of the data that were never documented, and this update broke those assumptions. This fixes that. Longer version follows, read on if you're interested in how the Props Explorer works.
So, this repository interacts pretty closely with https://github.com/Shopify/polaris-styleguide . The styleguide has a feature called the
Props Explorer
, which allows users to search through any given component's props in a tree-like manner, right from the styleguide, and check out their types, default values, names, etc.To be able to do this, we implemented the following pipeline on the styleguide:
polaris-react
package as a dependencytypedoc
on the types, to generate a JSON file representation of these typesWhen we updated to
@shopify/polaris
's latest version step 3 stopped working. Part of the problem is that it was failing silently, and thus hard to debug. We don't have a lot of documentation or tests written for the Props Explorer, so a lot of this exploration was manual guesswork.typedoc
parses the types generated by TS, and spits out an object. This object contains all the types and functions declared in thepolaris-react
codebase. The crux of the problem is thattypedoc
gives you limited information. It will tell you the signature and type of the properties of any function, but won't tell you what the name of the interface that the function implements is.To deal with this, the original writer of this code made an assumption that all component files would declare a
Props
interface, export it, and implement it as its props. This means that if you:Props
;The script breaks. Going forward we should look into ways of enforcing this consistently through a linting rule.
WHAT is this pull request doing?
Renaming and moving a few type interfaces to match the format expected by the Props Explorer.
How to 🎩
Build for the styleguide and check if the props explorer shows up