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

Use export * in utility indexes too #2636

Merged
merged 1 commit into from
Jan 22, 2020
Merged

Use export * in utility indexes too #2636

merged 1 commit into from
Jan 22, 2020

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Jan 20, 2020

WHY are these changes introduced?

Following on from #2619 and #2625 I looked at the utility index files and spotted that in almost all cases our index files rexport everything in the files they reference, or what they references is never used externally, so they can also use export * too.

WHAT is this pull request doing?

  • Updates utility indexes to use export * because doing things one way everywhere is easier than doing things one way in components and another way in utilities

I did run into some issues with some interfaces that get used as the type that gets pushed into a React context.

I could either have those as a type or export the interface. I figured exporting the interface was an acceptable compromise as "a slightly leaky internal export that doesn't bleed into our public exports" was better than "disabling our linting rule that prefers the usage of interfaces over types".

How to 🎩

Type check and tests pass

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2020

💦 Potential splash zone of changes introduced to src/**/*.tsx in this pull request:

Files modified18
Files potentially affected136

Details

All files potentially affected (total: 136)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🧩 src/components/ThemeProvider/ThemeProvider.tsx (total: 5)

Files potentially affected (total: 5)

🧩 src/utilities/app-bridge/index.ts (total: 23)

Files potentially affected (total: 23)

🧩 src/utilities/features/index.ts (total: 72)

Files potentially affected (total: 72)

🧩 src/utilities/frame/context.ts (total: 10)

Files potentially affected (total: 10)

🧩 src/utilities/frame/index.ts (total: 8)

Files potentially affected (total: 8)

🧩 src/utilities/i18n/index.ts (total: 99)

Files potentially affected (total: 99)

🧩 src/utilities/link/index.ts (total: 72)

Files potentially affected (total: 72)

🧩 src/utilities/media-query/context.tsx (total: 24)

Files potentially affected (total: 24)

🧩 src/utilities/media-query/index.ts (total: 22)

Files potentially affected (total: 22)

🧩 src/utilities/resource-list/context.ts (total: 7)

Files potentially affected (total: 7)

🧩 src/utilities/resource-list/index.ts (total: 6)

Files potentially affected (total: 6)

🧩 src/utilities/scroll-lock-manager/index.ts (total: 14)

Files potentially affected (total: 14)

🧩 src/utilities/scroll-lock-manager/scroll-lock-manager.ts (total: 17)

Files potentially affected (total: 17)

🧩 src/utilities/sticky-manager/index.ts (total: 48)

Files potentially affected (total: 48)

🧩 src/utilities/sticky-manager/sticky-manager.ts (total: 51)

Files potentially affected (total: 51)

🧩 src/utilities/theme/index.ts (total: 39)

Files potentially affected (total: 39)

🧩 src/utilities/unique-id/index.ts (total: 64)

Files potentially affected (total: 64)


This comment automatically updates as changes are made to this pull request.
Feedback, troubleshooting: open an issue or reach out on Slack in #polaris-tooling.

@BPScott BPScott force-pushed the export-star-utilities branch from aafb3dd to a290073 Compare January 20, 2020 21:45
Copy link
Contributor

@amrocha amrocha left a comment

Choose a reason for hiding this comment

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

Seems good, a few comments

@@ -2,9 +2,7 @@ import {isServer} from '../target';

export const SCROLL_LOCKING_ATTRIBUTE = 'data-lock-scrolling';

export const SCROLL_LOCKING_WRAPPER_ATTRIBUTE = 'data-lock-scrolling-wrapper';

export const SCROLL_LOCKING_CUSTOM_PROPERTY = '--scroll-lock-body-padding';
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure we can remove this?

Copy link
Member Author

@BPScott BPScott Jan 22, 2020

Choose a reason for hiding this comment

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

I checked for usages and there were none outside the current file, I then removed the export and it complained that it was never used inside this file either


export {Theme, ThemeConfig, CustomPropertiesLike, ColorScheme} from './types';
export {ThemeConfig} from './types';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not export * here?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a bunch of other types in that file that are used within this folder, but not externally. As most of this is going to be extracted into polaris-tokens pretty soon it didn't seem worth the refactoring to split this into a types and private-types file.

@BPScott BPScott merged commit 0885ae2 into master Jan 22, 2020
@BPScott BPScott deleted the export-star-utilities branch January 22, 2020 00:21
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