refactor(inline-error): migrate InlineError from Flow to TypeScript - #4728
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
WalkthroughAdds a typed ChangesInlineError component
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (7)
src/components/index.tssrc/components/inline-error/InlineError.js.flowsrc/components/inline-error/InlineError.stories.tsxsrc/components/inline-error/InlineError.tsxsrc/components/inline-error/__tests__/InlineError.test.tsxsrc/components/inline-error/index.js.flowsrc/components/inline-error/index.ts
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (7)
src/components/index.tssrc/components/inline-error/InlineError.js.flowsrc/components/inline-error/InlineError.stories.tsxsrc/components/inline-error/InlineError.tsxsrc/components/inline-error/__tests__/InlineError.test.tsxsrc/components/inline-error/index.js.flowsrc/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-" srcRepository: 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 -200Repository: 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 -250Repository: 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" doneRepository: 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()) PYRepository: box/box-ui-elements
Length of output: 3477
Keep the Flow and TypeScript prop contracts aligned.
InlineError.tsxacceptsReact.HTMLAttributes<HTMLDivElement>withtitleomitted, so native<div>props likeid,role, andaria-*are allowed.InlineError.js.flowcurrently only permitschildren,className, andtitle, which makes the Flow consumer contract narrower than TypeScript. Use a Flow div-props equivalent and omittitlefrom that spread, or keep flow-typed parity with the actualInlineNoticeFlow 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.
7baa6b3 to
912e291
Compare
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
src/components/inline-error/__tests__/__snapshots__/InlineError.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (7)
src/components/index.tssrc/components/inline-error/InlineError.js.flowsrc/components/inline-error/InlineError.stories.tsxsrc/components/inline-error/InlineError.tsxsrc/components/inline-error/__tests__/InlineError.test.tsxsrc/components/inline-error/index.js.flowsrc/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
912e291 to
977418e
Compare
Merge Queue Status
This pull request spent 13 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
Convert InlineError component to TypeScript
This PR converts
src/components/inline-errorfrom JavaScript with Flow to TypeScript.Changes
InlineError.jstoInlineError.tsxwith exportedInlineErrorPropsinterface<div>attributes throughReact.HTMLAttributesindex.jstoindex.ts, re-exporting the component and its typesInlineError.stories.jstoInlineError.stories.tsx__tests__/InlineError.test.jstoInlineError.test.tsx.js.flowfiles for backward compatibilityInlineErrorexports tosrc/components/index.tsTesting
src/components/inline-error; the test and snapshot passyarn lint:ts, ESLint, andflow checkpassComponents/InlineErrorstory builds successfullySummary by CodeRabbit
InlineErrorcomponent for inline error/validation messaging, with requiredtitleand message content.classNamefor styling and is available via the main components library exports.InlineError.