[NO JIRA][BpkAutosuggest] Migrate JS to TypeScript#4303
[NO JIRA][BpkAutosuggest] Migrate JS to TypeScript#4303
Conversation
- Convert all .js/.jsx source, test, and example files to .tsx/.ts - Remove Flow type annotations and PropTypes; replace with TypeScript interfaces - Use @ts-expect-error for untyped react-autosuggest import per decisions/imports-ts-suppressions.md - Move defaultProps defaults to destructuring parameters - Fix class component constructor to pass props per TypeScript strict mode - Add missing onSuggestionsClearRequested method caught by TypeScript - Remove now-unused @ts-expect-error directives from consumer examples/stories - Delete all original .js files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Migrates bpk-component-autosuggest (and its related examples/tests) from Flow/JS to TypeScript, removing Flow/PropTypes usage and tightening typings while keeping consumer-facing behavior consistent.
Changes:
- Converted component/test/example files to TypeScript and removed Flow annotations / PropTypes.
- Added/updated TypeScript typings around
react-autosuggestintegration (with@ts-expect-errorper repo decision). - Updated Storybook/examples and regenerated Jest snapshots for the migrated components.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/bpk-component-autosuggest/src/accessibility-test.tsx | Removes Flow pragma and adds TS annotations in accessibility test helpers. |
| packages/bpk-component-autosuggest/src/snapshots/BpkAutosuggestSuggestion-test.tsx.snap | Adds new snapshots for suggestion rendering after TS migration. |
| packages/bpk-component-autosuggest/src/snapshots/BpkAutosuggest-test.tsx.snap | Adds new snapshots for autosuggest rendering after TS migration. |
| packages/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.tsx | Replaces Flow/PropTypes with TS props and defaulting via destructuring. |
| packages/bpk-component-autosuggest/src/BpkAutosuggestSuggestion-test.tsx | Removes Flow pragma in tests. |
| packages/bpk-component-autosuggest/src/BpkAutosuggest.tsx | Adds TS types and @ts-expect-error for untyped react-autosuggest; updates renderInputComponent typing. |
| packages/bpk-component-autosuggest/src/BpkAutosuggest-test.tsx | Updates tests with TS annotations/casts. |
| packages/bpk-component-autosuggest/index.ts | Removes Flow pragma; keeps/clarifies TS exports. |
| packages/bpk-component-autosuggest/check-autosuggest-version-test.ts | Removes Flow pragma in version check test. |
| examples/bpk-component-autosuggest/stories.tsx | Updates example imports to use typed package exports. |
| examples/bpk-component-autosuggest/examples.tsx | Updates example imports to use typed package exports. |
| examples/bpk-component-autosuggest-legency/stories.tsx | Minor formatting change while migrating surrounding ecosystem to TS. |
| examples/bpk-component-autosuggest-legency/examples.tsx | Adds TS types, fixes constructor strictness, and adds missing clear handler method. |
| .claude/skills/bpk-js-to-ts-migration/SKILL.md | Adds a migration playbook documenting the repo’s preferred Flow→TS patterns and suppressions. |
Comments suppressed due to low confidence (4)
examples/bpk-component-autosuggest-legency/stories.tsx:20
- There are now two blank lines between the file header and the first import. Please remove the extra empty line to keep formatting consistent (or run Prettier).
packages/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.tsx:34 Propsis defined asHTMLAttributes<HTMLElement> & { className?: string | null; ... }, butHTMLAttributesalready definesclassName?: string, so the intersection collapsesclassNameback tostring(i.e.,nullwon’t actually be allowed). If you want to preserve the previous API (defaultProps usednull), useOmit<HTMLAttributes<HTMLElement>, 'className'>and then re-addclassName?: string | null.
packages/bpk-component-autosuggest/src/BpkAutosuggest.tsx:74- The
inputRefcallback is typed as(element: HTMLInputElement)but it can be invoked withnull(React ref callbacks receivenullon unmount, and yourInputComponentProps.ref/inputReftypes already allownull). Consider typing it asHTMLInputElement | nulland guarding before callingref(...)/inputRef(...)to avoid runtime errors during unmount.
packages/bpk-component-autosuggest/src/BpkAutosuggest.tsx:66 - There’s trailing whitespace on the blank line immediately before
<BpkInput(line 66). This tends to fail formatting/linting checks; please remove the extra spaces (or run Prettier).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // @ts-expect-error: BpkAutosuggestSuggestion is a Flow-based JS file without type declarations. | ||
| // TODO: This will be removed once the file is migrated to TypeScript. | ||
| import BpkAutosuggestSuggestion from '../../packages/bpk-component-autosuggest/src/BpkAutosuggestSuggestion'; | ||
| import BpkAutosuggest,{ BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; |
There was a problem hiding this comment.
Import formatting is off (BpkAutosuggest,{ ... }). This should be formatted as BpkAutosuggest, { ... } (and generally left to Prettier) to match repo style and avoid churn in future formatting passes.
| import BpkAutosuggest,{ BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; | |
| import BpkAutosuggest, { BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; |
| // BpkAutosuggestSuggestion is a Flow-based JS file without type declarations. | ||
| // TODO: This will be removed once the file is migrated to TypeScript. | ||
| import BpkAutosuggestSuggestion from '../../packages/bpk-component-autosuggest/src/BpkAutosuggestSuggestion'; | ||
| import BpkAutosuggest,{ BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; |
There was a problem hiding this comment.
Import formatting is off (BpkAutosuggest,{ ... }). Please format this as BpkAutosuggest, { ... } (or run Prettier) to match the repo’s standard import style.
| import BpkAutosuggest,{ BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; | |
| import BpkAutosuggest, { BpkAutosuggestSuggestion } from '../../packages/bpk-component-autosuggest'; |
|
Visit https://backpack.github.io/storybook-prs/4303 to see this build running in a browser. |
…r autosuggest TS migration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fix) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Visit https://backpack.github.io/storybook-prs/4303 to see this build running in a browser. |
Remember to include the following changes:
[Clover-123][BpkButton] Updating the colourREADME.md(If you have created a new component)README.md