-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Rename Option and Group types in Select to workaround typedoc oddness #830
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
From @AndrewMusgrave on Slack "Don’t ask me why but this seems to be the culprit (719ca66). I can’t for the life of me see why though" I think that file changed the order in which typedoc discovered files which resulted in a different |
Props as SelectProps, | ||
Option as SelectOption, | ||
Group as SelectGroup, | ||
SelectOption, |
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.
As we're not changing the export names in src/components/index.ts
this is not a breaking change to our public API
import Spinner from '../Spinner'; | ||
import {withAppProvider, WithAppProviderProps} from '../AppProvider'; | ||
import Select, {Option} from '../Select'; | ||
import Select, {SelectOption} from '../Select'; |
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.
I tried changing just the import statement to import Select, {Option as SelectOption} from '../Select';
but that did not work.
yarn run typedoc
compiled correctly but when viewing the types it just said SelectOption[]
instead of exposing what that intersection type referred to (i.e. string | StrictOption[]
) like on production.
235d100
to
0f7ed01
Compare
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.
🎩
0f7ed01
to
bc02877
Compare
Typedoc (which we use for generating prop tables on the styleguide) has a bug in it where it doesn't correctly resolve types that are imported from a different file (or we're using it wrong). Instead of looking at imports it seems to look at a global bucket of names. In this case there was a clash between Option (as living in Select) and Option (as living in OptionList/components). Work around this by renaming Select's Option to "SelectOption". This allows our type docmentation generation in the styleguide to work correctly. Strictly speaking the change to SelectGroup isn't needed but i think "SelectOption and SelectGroup" sounds nicer than "SelectOption and Group".
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.
I think that file changed the order in which typedoc discovered files which resulted in a different Option being set as the "global Option" (for want of a better phrase).
Makes sense 🎩 💯
WHY are these changes introduced?
Typedoc (which we use for generating prop tables on the styleguide) has
a bug in it where it doesn't correctly resolve types that are imported
from a different file (or we're using it wrong).
Instead of looking at imports it seems to look at a global bucket of
names. In this case there was a clash between Option (as living in Select)
and Option (as living in OptionList/components).
This resulted it it thinking that the type for ResourceList -> sortOptions was
src/components/OptionList/components/Option/Option.tsx
's default export instead of the type insrc/components/Select/Select.tsx
WHAT is this pull request doing?
Work around this by renaming Select's Option to "SelectOption".
This allows our type documentation generation in the styleguide to work
correctly.
Strictly speaking the change to SelectGroup isn't needed but i think
"SelectOption and SelectGroup" sounds nicer than "SelectOption and
Group".
How to 🎩
yarn run typedoc
and swear loudly because it fails.yarn build-consumer polaris-styleguide
yarn run typedoc
again and see that it runs without errors. Cheer / run your temples /swear loudly again.yarn dev
and see that the prop table on the ResourceList page correctly states thatsortOptions
has the typingstring | StrictOption[]
just like in production