backpack
backpack copied to clipboard
[BpkLink] Migrate component to TypeScript
Migrates BpkLink and BpkButtonLink components from JavaScript (Flow) to TypeScript.
Changes
-
Component files:
BpkLink.tsx,BpkButtonLink.tsx,themeAttributes.ts -
Test files: All test files converted to
.tsxwith typed refs -
Package index:
index.tswith exportedBpkLinkPropsandBpkButtonLinkPropstypes -
Storybook:
examples.tsxandstories.tsx -
Figma: Added required
hrefprop to example -
Downstream fixes: Removed unused
@ts-expect-errordirectives from components that import frombpk-component-link(bottom-sheet, breadcrumb, drawer, info-banner, modal, navigation-bar, popover, rtl-toggle, card-list examples) -
Type fixes:
- Updated
BpkNavigationBarButtonLinkto usetypeof BpkButtonLinkfor component props - Fixed
BpkRtlToggleto use proper ReactMouseEventtype - Changed
BpkLinkProps to extendAnchorHTMLAttributes<HTMLAnchorElement>instead of using index signature[rest: string]: anyfor better Storybook documentation generator (react-docgen) compatibility - Changed
BpkButtonLinkProps to extendButtonHTMLAttributes<HTMLButtonElement>instead of using index signature for consistency and better Storybook docgen - Updated
classNameandreltypes to match HTML attributes (removingnullfrom union types)
- Updated
-
Accessibility: Ensured
hrefprop remains required onBpkLinkto match original Flow type and prevent accessibility regression (anchor without href is an accessibility issue) -
Bug fixes: Fixed
BpkBreadcrumbItemandBpkInfoBannerInnerto provide valid href values when using BpkLink
Usage
import BpkLink, { BpkButtonLink, type BpkLinkProps } from '@skyscanner/backpack-web/bpk-component-link';
<BpkLink href="/path" alternate>Link text</BpkLink>
<BpkButtonLink onClick={handleClick}>Button link</BpkButtonLink>
Remember to include the following changes:
- [x] Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g
[Clover-123][BpkButton] Updating the colour - [ ]
README.md(If you have created a new component) - [ ] Component
README.md - [x] Tests
- [x] Accessibility tests
- The following checks were performed:
- [ ] Ability to navigate using a keyboard only
- [ ] Zoom functionality (Deque University explanation):
- [ ] The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
- [ ] Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
- [ ] Ability to navigate using a screen reader only
- The following checks were performed:
- [x] Storybook examples created/updated
- [ ] For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here
Original prompt
This section details on the original issue you should resolve
<issue_title>Migrate BpkLink component to Typescript</issue_title> <issue_description>I want to migrate BpkLink component and all its tests and storybook examples to Typescript</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes Skyscanner/backpack#4062
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.