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

Fix imports for commonly-named components #398

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

nmanu1
Copy link
Contributor

@nmanu1 nmanu1 commented Oct 6, 2023

This PR fixes imports for commonly-named components like Container and Text by manually writing their imports to the file before calling ts-morphs fixMissingImports function. Previously, this function would often add an incorrect import in the case of Container and not add any import in the case of Text, which is also a built-in interface in React.

J=SLAP-2587
TEST=auto, manual

Added postcss to the test site and saw that without these changes, Container was imported from postcss (which also has a named export called Container), and that with these changes, Container is correctly imported from src/components. Also saw that the behavior for Text was fixed (i.e. an import was actually added for a Text component rather than it trying to use the React type).

@tmeyer2115
Copy link
Contributor

This PR fixes imports for commonly-named components like Container and Text by manually writing their imports to the file before calling ts-morphs fixMissingImports function. Previously, this function would often add an incorrect import in the case of Container and not add any import in the case of Text, which is also a built-in interface in React.

J=SLAP-2587 TEST=auto, manual

I wasn't able to replicate the incorrect Container import in the test-site because we don't have any packages like postcss that have another named export called Container. But, I was able to see the behavior for Text fixed (i.e. an import was actually added for a Text component rather than it trying to use the React type).

Since the impetus of the item was the incorrect Container import, could you add postcss to the test site? I'd like to verify that we've fixed the bug for Container. We don't need to check in those changes to the test site, I'd just like us to verify it manually.

@nmanu1
Copy link
Contributor Author

nmanu1 commented Oct 9, 2023

Since the impetus of the item was the incorrect Container import, could you add postcss to the test site? I'd like to verify that we've fixed the bug for Container. We don't need to check in those changes to the test site, I'd just like us to verify it manually.

Added postcss to the test site and confirmed that without the changes in this PR, Container was imported from postcss and with the changes, Container is correctly imported from src/components!

@nmanu1 nmanu1 merged commit 309fd3d into main Oct 9, 2023
15 checks passed
@nmanu1 nmanu1 deleted the dev/fix-container-imports branch October 9, 2023 13:27
@tmeyer2115 tmeyer2115 mentioned this pull request Oct 11, 2023
tmeyer2115 added a commit that referenced this pull request Oct 11, 2023
## Features
- When specifying a Component's Prop Interface, you can now use the
`extends` keyword. (#395)

## Changes
- Cached, pre-bundled dependencies are now ignored when starting Studio.
Studio's Vite instance will pre-bundle all dependencies each time Studio
is started. (#405)
- Props with a Tooltip now have an Info Icon (#403)

## Fixes
- Incorrect imports for commonly-named Components have been fixed.
(#398)
alextaing pushed a commit that referenced this pull request Oct 11, 2023
## Features
- When specifying a Component's Prop Interface, you can now use the
`extends` keyword. (#395)

## Changes
- Cached, pre-bundled dependencies are now ignored when starting Studio.
Studio's Vite instance will pre-bundle all dependencies each time Studio
is started. (#405)
- Props with a Tooltip now have an Info Icon (#403)

## Fixes
- Incorrect imports for commonly-named Components have been fixed.
(#398)
@alextaing alextaing mentioned this pull request Oct 30, 2023
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