Skip to content

refactor(image-tooltip): migrate ImageTooltip from Flow to TypeScript - #4770

Open
bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-image-tooltip
Open

refactor(image-tooltip): migrate ImageTooltip from Flow to TypeScript#4770
bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-image-tooltip

Conversation

@bonchevskyi

@bonchevskyi bonchevskyi commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Convert ImageTooltip component to TypeScript

This PR converts src/components/image-tooltip from JavaScript with Flow to TypeScript.

Changes

  • Converted getTestImageSrc.js to getTestImageSrc.ts (remaining Flow module in an otherwise TypeScript folder)
  • Updated ImageTooltipProps / ImageTooltipContentProps to interfaces; re-exported ImageTooltipProps from index.ts
  • Created getTestImageSrc.js.flow for backward compatibility
  • Removed stale @ts-ignore flow import directives now that Tooltip and getTestImageSrc are TypeScript

Contract

  • Declared Flow props contract preserved (requiredness, accepted values, defaults, exports)

Testing

  • Ran tests for src/components/image-tooltip; all 2 pass with snapshots matching previous output
  • yarn lint:ts and flow check pass
  • Manually verified in Storybook (Components/ImageTooltip) that behavior is unchanged

Summary by CodeRabbit

  • Refactor

    • Updated ImageTooltip type definitions for improved type safety and clarity.
    • Exposed ImageTooltipProps through the component’s public exports.
    • Simplified internal image-loading callback definitions.
  • Tests

    • Improved test image asset handling across supported type-checking environments.
    • Removed obsolete type-check suppression comments from stories and tests.

@bonchevskyi
bonchevskyi requested a review from a team as a code owner August 11, 2026 14:39
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

ImageTooltip now uses TypeScript interfaces and type-only imports. Its public props type is re-exported, content helper typing is simplified, and test image compatibility modules support both Flow and TypeScript.

Changes

ImageTooltip TypeScript migration

Layer / File(s) Summary
Typed component contracts and exports
src/components/image-tooltip/ImageTooltip.tsx, src/components/image-tooltip/ImageTooltipContent.tsx, src/components/image-tooltip/index.ts
ImageTooltipProps now extends Omit<TooltipProps, 'text'>. Content props use a non-exported interface. The public props type is re-exported.
Test asset compatibility cleanup
src/components/image-tooltip/getTestImageSrc.*, src/components/image-tooltip/ImageTooltip.stories.tsx
Test image modules provide default exports for Flow and TypeScript. Obsolete import suppression comments are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: ready-to-merge

Suggested reviewers: vitali-usik, tjiang-box, jpan-box

Poem

A rabbit reviews the tooltip bright,
With typed props neat and exports right.
Flow shadows fade, images hop,
Arrow functions never stop.
“Merge,” says the bunny, “what a delight!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: migrating ImageTooltip from Flow to TypeScript.
Description check ✅ Passed The description explains the migration, lists the changes, states contract preservation, and documents testing and verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/image-tooltip/getTestImageSrc.ts (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer @ts-expect-error or add a shared PNG declaration.

@ts-ignore suppresses every diagnostic on the import. Use @ts-expect-error when the missing declaration is intentional, or add a shared *.png declaration and remove the suppression.

The supplied TypeScript context states that the directive exists because the PNG asset has no declaration; verify the repository's ambient asset declarations before choosing the fix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/image-tooltip/getTestImageSrc.ts` around lines 1 - 2, Replace
the broad `@ts-ignore` on the testImageSrc PNG import with `@ts-expect-error` if the
repository lacks an ambient PNG declaration; otherwise add or reuse a shared
*.png declaration and remove the suppression. Verify existing asset declarations
before selecting the approach.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/image-tooltip/ImageTooltipContent.tsx`:
- Around line 6-15: Restore the public export on the ImageTooltipContentProps
interface so consumers can continue importing this type from the module.
Preserve the existing interface fields and contract; only update its declaration
visibility.

---

Nitpick comments:
In `@src/components/image-tooltip/getTestImageSrc.ts`:
- Around line 1-2: Replace the broad `@ts-ignore` on the testImageSrc PNG import
with `@ts-expect-error` if the repository lacks an ambient PNG declaration;
otherwise add or reuse a shared *.png declaration and remove the suppression.
Verify existing asset declarations before selecting the approach.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 452ab25d-bb0e-46c2-8127-57f2ff94af12

📥 Commits

Reviewing files that changed from the base of the PR and between 5d273fe and a33411d.

📒 Files selected for processing (8)
  • src/components/image-tooltip/ImageTooltip.stories.tsx
  • src/components/image-tooltip/ImageTooltip.tsx
  • src/components/image-tooltip/ImageTooltipContent.tsx
  • src/components/image-tooltip/__tests__/ImageTooltip.test.tsx
  • src/components/image-tooltip/__tests__/ImageTooltipContent.test.tsx
  • src/components/image-tooltip/getTestImageSrc.js.flow
  • src/components/image-tooltip/getTestImageSrc.ts
  • src/components/image-tooltip/index.ts
💤 Files with no reviewable changes (3)
  • src/components/image-tooltip/tests/ImageTooltipContent.test.tsx
  • src/components/image-tooltip/tests/ImageTooltip.test.tsx
  • src/components/image-tooltip/ImageTooltip.stories.tsx

Comment thread src/components/image-tooltip/ImageTooltipContent.tsx
@bonchevskyi
bonchevskyi force-pushed the refactor/flow-to-ts-image-tooltip branch from a33411d to 7307fb5 Compare August 12, 2026 11:26
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