Skip to content

refactor(inline-error): migrate InlineError from Flow to TypeScript - #4728

Merged
mergify[bot] merged 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-inline-error
Jul 29, 2026
Merged

refactor(inline-error): migrate InlineError from Flow to TypeScript#4728
mergify[bot] merged 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-inline-error

Conversation

@bonchevskyi

@bonchevskyi bonchevskyi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Convert InlineError component to TypeScript

This PR converts src/components/inline-error from JavaScript with Flow to TypeScript.

Changes

  • Converted InlineError.js to InlineError.tsx with exported InlineErrorProps interface
  • Added support for native <div> attributes through React.HTMLAttributes
  • Converted index.js to index.ts, re-exporting the component and its types
  • Converted InlineError.stories.js to InlineError.stories.tsx
  • Converted __tests__/InlineError.test.js to InlineError.test.tsx
  • Renamed the Jest snapshot to match the TypeScript test
  • Created .js.flow files for backward compatibility
  • Added InlineError exports to src/components/index.ts

Testing

  • Ran tests for src/components/inline-error; the test and snapshot pass
  • Confirmed the regenerated snapshot matches the previous output
  • yarn lint:ts, ESLint, and flow check pass
  • Verified the Components/InlineError story builds successfully

Summary by CodeRabbit

  • New Features
    • Added an InlineError component for inline error/validation messaging, with required title and message content.
    • Supports optional className for styling and is available via the main components library exports.
  • Documentation
    • Added a Storybook story for InlineError.
  • Tests
    • Added a Jest snapshot test to verify the component renders as expected.

@bonchevskyi
bonchevskyi requested a review from a team as a code owner July 29, 2026 10:57
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9627e4ea-ff5c-4331-8512-03dc2cdffa6b

📥 Commits

Reviewing files that changed from the base of the PR and between 912e291 and 977418e.

⛔ Files ignored due to path filters (1)
  • src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/components/index.ts
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/InlineError.tsx
  • src/components/inline-error/__tests__/InlineError.test.tsx
  • src/components/inline-error/index.js.flow
  • src/components/inline-error/index.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/components/inline-error/index.ts
  • src/components/inline-error/tests/InlineError.test.tsx
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/index.js.flow
  • src/components/inline-error/InlineError.tsx
  • src/components/index.ts

Walkthrough

Adds a typed InlineError React wrapper around InlineNotice, exports it through component barrels, and adds Flow support, a Storybook story, and a snapshot test.

Changes

InlineError component

Layer / File(s) Summary
InlineError implementation
src/components/inline-error/InlineError.tsx, src/components/inline-error/InlineError.js.flow
Defines typed props and renders InlineNotice with type="error" while forwarding props.
Exports and validation
src/components/inline-error/index.ts, src/components/inline-error/index.js.flow, src/components/index.ts, src/components/inline-error/InlineError.stories.tsx, src/components/inline-error/__tests__/InlineError.test.tsx
Adds module and public barrel exports, a Storybook story, and snapshot coverage.

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

Possibly related PRs

Suggested labels: ready-to-merge

Poem

I’m a bunny with an error to show,
Wrapped in a notice, neatly in tow.
Props hop through, exports shine,
Stories and snapshots keep things fine.
Thump, thump—InlineError is online!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: migrating InlineError from Flow to TypeScript.
Description check ✅ Passed The description covers the migration, key file changes, and testing results, which is sufficient for this repository's template.
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

🤖 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/inline-error/InlineError.js.flow`:
- Around line 5-10: Update the Props type in InlineError.js.flow to match
InlineError.tsx: include the Flow equivalent of native HTMLDivElement attributes
while omitting the native title field, and retain the wrapper’s explicit
children, className, and title definitions. If InlineNotice’s Flow props are the
intended contract instead, reuse that existing type to preserve parity.
🪄 Autofix (Beta)

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: ee1b804f-f081-443e-8f89-70d310ed8c74

📥 Commits

Reviewing files that changed from the base of the PR and between 411145c and 7baa6b3.

⛔ Files ignored due to path filters (1)
  • src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/components/index.ts
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/InlineError.tsx
  • src/components/inline-error/__tests__/InlineError.test.tsx
  • src/components/inline-error/index.js.flow
  • src/components/inline-error/index.ts

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 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/inline-error/InlineError.js.flow`:
- Around line 5-10: Update the Props type in InlineError.js.flow to match
InlineError.tsx: include the Flow equivalent of native HTMLDivElement attributes
while omitting the native title field, and retain the wrapper’s explicit
children, className, and title definitions. If InlineNotice’s Flow props are the
intended contract instead, reuse that existing type to preserve parity.
🪄 Autofix (Beta)

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: ee1b804f-f081-443e-8f89-70d310ed8c74

📥 Commits

Reviewing files that changed from the base of the PR and between 411145c and 7baa6b3.

⛔ Files ignored due to path filters (1)
  • src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/components/index.ts
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/InlineError.tsx
  • src/components/inline-error/__tests__/InlineError.test.tsx
  • src/components/inline-error/index.js.flow
  • src/components/inline-error/index.ts
🛑 Comments failed to post (1)
src/components/inline-error/InlineError.js.flow (1)

5-10: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 "ElementProps<'div'>|HTMLAttributes.*div|aria-" src

Repository: box/box-ui-elements

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching InlineError:\n'
fd -a 'InlineError\.(js\.flow|tsx|jsx)$' . || true

printf '\nTypeScript InlineError excerpt:\n'
fd 'InlineError\.tsx$' . -x sh -c 'echo "--- $1"; sed -n "1,140p" "$1"' sh {}

printf '\nFlow InlineError excerpt:\n'
fd 'InlineError\.js\.flow$' . -x sh -c 'echo "--- $1"; sed -n "1,120p" "$1"' sh {}

printf '\nPackage files relevant to Flow/TS deps:\n'
for f in package.json pnpm-lock.yaml yarn.lock package-lock.json flow-typed; do
  [ -e "$f" ] && { echo "--- $f"; sed -n "1,180p" "$f"; }
done

printf '\nReact.Flow imports/types in src (focused):\n'
rg -n "React\.ElementProps|ElementProps<'div'|HTMLAttributes<.*div|declare type .*React|declare module 'react'" src --glob '!src/**/*.snap*' | head -200

Repository: box/box-ui-elements

Length of output: 19065


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'InlineNotice props:\n'
for f in $(fd 'InlineNotice\.(js\.flow|tsx)$' src/components/inline-notice); do
  echo "--- $f"
  sed -n '1,140p' "$f"
done

printf '\nFlow component wrappers importing spread props:\n'
rg -n "type Props = \\{|extends .*Props|omit|Omit|\\(...props|\\{\\.\\.\\." src/components --glob '*.js.flow' | head -200

printf '\nFocused Flow declarations for React props utility/type patterns:\n'
rg -n "React\\.(ElementProps|ElementProps<Omit|ElementProps<\\{|Omit<.*React|ReactNode|Node\\)|type .*Props = \\{|HTMLAttributes<.*div|DivAttributes|Div|div" src --glob '*.js.flow' | head -250

Repository: box/box-ui-elements

Length of output: 15596


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Candidate inline-notice files:\n'
fd 'InlineNotice\.(js\.flow|tsx)$' src/components/inline-notice || true

for f in $(fd 'InlineNotice\.(js\.flow|tsx)$' src/components/inline-notice); do
  echo "--- $f"
  sed -n '1,220p' "$f"
done

printf '\nFlow-specific React prop utility usages:\n'
rg -n "React\.(ElementProps|ElementProps<Omit|Omit<.*React|HTMLAttributes<|HTMLProps<|Omit<|react-dom/client|React\.DOMProps|DOMProps" src --glob '*.js.flow' | head -250

printf '\nReact imports in Flow files:\n'
rg -n "^import \\* as React from 'react';|^import React from 'react';" src --glob '*.js.flow' | head -100

printf '\nTypeScript InlineNotice props excerpt:\n'
for f in $(fd 'InlineNotice\.tsx$' src/components/inline-notice); do
  echo "--- $f"
  sed -n '1,220p' "$f"
done

Repository: box/box-ui-elements

Length of output: 416


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Candidate inline-notice files:\n'
fd 'InlineNotice\.(js\.flow|tsx)$' src/components/inline-notice || true

for f in $(fd '\.tsx$' src/components/inline-notice); do
  echo "--- $f"
  sed -n '1,220p' "$f"
done

for f in $(find src/components/inline-notice -maxdepth 1 \( -name '*.js.flow' -o -name '*.js' \) -print); do
  echo "--- $f"
  sed -n '1,220p' "$f"
done

printf '\nFlow-specific React/React-DOM prop declarations:\n'
rg -n "React\.(ElementProps|Omit<.*React|HTMLAttributes<|Omit<.*HTML|DOMProps|React\.DOMProps" src --glob '*.js.flow' | head -250 || true

printf '\nRead-only structural checks for inline-error TypeScript Flow parity:\n'
python3 - <<'PY'
from pathlib import Path
tsx = Path('src/components/inline-error/InlineError.tsx').read_text()
flow = Path('src/components/inline-error/InlineError.js.flow').read_text()
ts_inline_notice_path = 'src/components/inline-notice/InlineNotice.tsx'
flow_inline_notice_path = 'src/components/inline-notice/InlineNotice.js.flow'
print('tsx has native div omitted title contract:', "Omit<React.HTMLAttributes<HTMLDivElement>, 'title'>" in tsx)
print('tsx spreads props:', '{...props}' in tsx)
print('flow has native div prop type:', "ElementProps" in flow or "Omit" in flow or "HTMLAttributes" in flow)
print('flow explicit properties:', [line.strip() for line in flow.splitlines() if any(k in line for k in ['children', 'className', 'title'])])
print('tsx flow props identical excluding Omitted native fields?:', tsx.split('export interface InlineErrorProps')[1].split('const InlineError')[0].strip() <= """extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
    /** Contents of the inline error */
    children: React.ReactNode;
    /** Title of the inline error. */
    title: React.ReactNode;
}""".strip())
PY

Repository: box/box-ui-elements

Length of output: 3477


Keep the Flow and TypeScript prop contracts aligned.

InlineError.tsx accepts React.HTMLAttributes<HTMLDivElement> with title omitted, so native <div> props like id, role, and aria-* are allowed. InlineError.js.flow currently only permits children, className, and title, which makes the Flow consumer contract narrower than TypeScript. Use a Flow div-props equivalent and omit title from that spread, or keep flow-typed parity with the actual InlineNotice Flow props if this wrapper should not expose native div props.

🤖 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/inline-error/InlineError.js.flow` around lines 5 - 10, Update
the Props type in InlineError.js.flow to match InlineError.tsx: include the Flow
equivalent of native HTMLDivElement attributes while omitting the native title
field, and retain the wrapper’s explicit children, className, and title
definitions. If InlineNotice’s Flow props are the intended contract instead,
reuse that existing type to preserve parity.

@bonchevskyi
bonchevskyi force-pushed the refactor/flow-to-ts-inline-error branch from 7baa6b3 to 912e291 Compare July 29, 2026 12:43

@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

🤖 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/inline-error/InlineError.tsx`:
- Around line 4-10: Update InlineErrorProps to extend
React.HTMLAttributes<HTMLDivElement> while omitting the native title property,
preserving its existing React.ReactNode title definition and enabling standard
div attributes and event handlers.
🪄 Autofix (Beta)

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: d56362ba-a0ad-4174-ad5c-840d4ecfd417

📥 Commits

Reviewing files that changed from the base of the PR and between 7baa6b3 and 912e291.

⛔ Files ignored due to path filters (1)
  • src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/components/index.ts
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/InlineError.tsx
  • src/components/inline-error/__tests__/InlineError.test.tsx
  • src/components/inline-error/index.js.flow
  • src/components/inline-error/index.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/components/inline-error/InlineError.js.flow
  • src/components/inline-error/index.ts
  • src/components/index.ts
  • src/components/inline-error/tests/InlineError.test.tsx
  • src/components/inline-error/InlineError.stories.tsx
  • src/components/inline-error/index.js.flow

Comment thread src/components/inline-error/InlineError.tsx Outdated
@bonchevskyi
bonchevskyi force-pushed the refactor/flow-to-ts-inline-error branch from 912e291 to 977418e Compare July 29, 2026 12:59
@mergify

mergify Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-07-29 17:14 UTC · Rule: Automatic strict merge · triggered by rule Automatic merge queue
  • Checks skipped · PR is already up-to-date
  • Merged2026-07-29 17:14 UTC · at 977418e618214b693ddab3435d760ac673a975aa · squash

This pull request spent 13 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Summary
    • check-neutral = Summary
    • check-skipped = Summary
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_test_build
    • check-neutral = lint_test_build
    • check-skipped = lint_test_build
  • any of [🛡 GitHub branch protection]:
    • check-success = license/cla
    • check-neutral = license/cla
    • check-skipped = license/cla
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_pull_request
    • check-neutral = lint_pull_request
    • check-skipped = lint_pull_request

@mergify
mergify Bot merged commit dc07626 into box:master Jul 29, 2026
10 of 11 checks passed
@mergify mergify Bot removed the queued label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants