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: Fix image import related type errors #9214

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Apr 12, 2024

Description

There have been type errors showing up on some PRs relating to image imports; TypeScript interprets them as strings, but we have them typed as ImageSourcePropType. The mismatch is there because these image imports are modified later in the build system.

Normally this is handled by our type declarations, which declare upfront which types these imports should have. But on some PRs, it seems that TypeScript will evaluate these declarations too late, after files including image imports.

I had trouble reproducing this problem on main, but it can be seen in the PR #8828 (commit b027cfa). If you include this change on that branch, it resolves the problem.

Related issues

Resolves lint error on #8828

Manual testing steps

Patch this change onto #8828 and see that the yarn lint:tsc command succeeds

Screenshots/Recordings

N/A

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

There have been type errors showing up on some PRs relating to image
imports; TypeScript interprets them as strings, but we have them typed
as `ImageSourcePropType`. The mismatch is there because these image
imports are modified later in the build system.

Normally this is handled by our type declarations, which declare
upfront which types these imports should have. But on some PRs, it
seems that TypeScript will evaluate these declarations too late, after
files including image imports.

I had trouble reproducing this problem on `main`, but it can be seen
in the PR #8828 (commit b027cfa). If
you include this change on that branch, it resolves the problem.
@Gudahtt Gudahtt marked this pull request as ready for review April 12, 2024 12:08
@Gudahtt Gudahtt requested a review from a team as a code owner April 12, 2024 12:08
@Gudahtt Gudahtt added team-mobile-platform No QA Needed Apply this label when your PR does not need any QA effort. labels Apr 12, 2024
Copy link

sonarcloud bot commented Apr 12, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@Gudahtt
Copy link
Member Author

Gudahtt commented Apr 12, 2024

This should not require E2E tests because it only affects one lint check. The change is to the TSConfig used just for the lint:tsc job, it has no impact upon the application or build process.

Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@Gudahtt Gudahtt merged commit 6cdbd57 into main Apr 12, 2024
37 of 38 checks passed
@Gudahtt Gudahtt deleted the fix-image-import-related-type-errors branch April 12, 2024 13:06
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
@metamaskbot metamaskbot added the release-7.22.0 Issue or pull request that will be included in release 7.22.0 label Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
No QA Needed Apply this label when your PR does not need any QA effort. release-7.22.0 Issue or pull request that will be included in release 7.22.0 team-mobile-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants