Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[bpk-component-map] Migrate to TypeScript - #4762

Merged
Iris Li (wpe1arhy) merged 12 commits into
mainfrom
ts-migration/bpk-component-map
Jul 22, 2026
Merged

Iris Li (wpe1arhy) merged 12 commits into
mainfrom
ts-migration/bpk-component-map

Conversation

@gert-janvercauteren

@gert-janvercauteren Gert-Jan Vercauteren (gert-janvercauteren) commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrates bpk-component-map from JavaScript to TypeScript
  • Replaces prop-types with TypeScript interfaces
  • Converts defaultProps to ES6 destructure defaults
  • Removes Flow type annotations
  • Renames .js source/test/story files to .tsx/.ts

Behaviour change: onRegionChange center argument shape

On main, onRegionChange received a raw google.maps.LatLng object as its second argument (consumers had to call .lat()/.lng() on it). The old Flow type declared LatLong but the runtime value never matched.

This PR normalises the value to { latitude, longitude } so the runtime shape actually matches the declared LatLong type. This is arguably a bug fix, but consumers calling .lat()/.lng() on the center argument will break. The minor label covers this.

Closes #4749

Migrates bpk-component-map from JavaScript to TypeScript as described in #4749.

- Replaced prop-types with TypeScript interfaces
- Converted defaultProps to ES6 destructure defaults
- Renamed .js source/test/story files to .tsx/.ts
- Removed Flow type annotations
- Preserved Apache 2.0 license headers

Closes #4749
Copilot AI review requested due to automatic review settings June 26, 2026 09:24

Copilot AI 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.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Migrates bpk-component-map toward TypeScript by replacing Flow/PropTypes with TS types and updating stories/tests accordingly.

Changes:

  • Removed Flow pragmas and prop-types, introducing TypeScript types/interfaces.
  • Updated marker tests/snapshots for data-testid and adjusted story typing.
  • Introduced/updated shared types (e.g., LatLong, libraries list) and some ref typing.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-map/src/withGoogleMapsScript.js Replaces PropTypes/Flow with TS generics and library unions.
packages/backpack-web/src/bpk-component-map/src/themeAttributes.js Adds TS annotations to theme attribute arrays.
packages/backpack-web/src/bpk-component-map/src/common-types.js Removes PropTypes and keeps only TS LatLong type.
packages/backpack-web/src/bpk-component-map/src/snapshots/BpkIconMarker-test.js.snap Updates snapshot to use data-testid.
packages/backpack-web/src/bpk-component-map/src/DefaultLoadingElement.js Removes Flow pragma.
packages/backpack-web/src/bpk-component-map/src/BpkOverlayView.js Migrates props typing from Flow/PropTypes to TS.
packages/backpack-web/src/bpk-component-map/src/BpkMap.stories.js Removes PropTypes-based story helpers and adds TS types/meta.
packages/backpack-web/src/bpk-component-map/src/BpkMap.js Replaces PropTypes/Flow with TS types and ref typing; adjusts region change payload.
packages/backpack-web/src/bpk-component-map/src/BpkIconMarkerBackground.js Adds TS typings via SVGProps and optional flags.
packages/backpack-web/src/bpk-component-map/src/BpkIconMarkerBackground-test.js Removes Flow pragma.
packages/backpack-web/src/bpk-component-map/src/BpkIconMarker.js Replaces PropTypes/Flow with TS types and updates click handling.
packages/backpack-web/src/bpk-component-map/src/BpkIconMarker-test.js Updates mock typing and switches to data-testid in test.
packages/backpack-web/src/bpk-component-map/src/BpkBasicMapMarker.tsx Cleans up imports and uses TS types for LatLong.
packages/backpack-web/src/bpk-component-map/src/BpkBasicMapMarker-test.js Adds mock typing similar to other tests.
packages/backpack-web/src/bpk-component-map/index.js Removes Flow pragma.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@skyscanner-backpack-bot

skyscanner-backpack-bot Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 3290ff4

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…ppressions.md

Replace @ts-ignore with @ts-expect-error for untyped imports.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
…ts-suppressions.md

Replace @ts-ignore with @ts-expect-error for bpk-storybook-utils untyped import.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
…ppressions

- Fix @ts-expect-error position in calendar/index.ts (must precede the 'from' line)
- Remove @ts-expect-error in BpkBasicMapMarker: BpkOverlayView and common-types are
  now TypeScript on this branch so suppressions are no longer needed.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@wpe1arhy Iris Li (wpe1arhy) 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.

Code review

1 issue on the onRegionChange callback contract. Reviewed with the Backpack multi-agent checklist.

🤖 Generated with Claude Code

Comment on lines 152 to 160
onDragEnd={() => {
if (ref && ref.current && onRegionChange) {
onRegionChange(ref.current.getBounds(), ref.current.getCenter());
const mapBounds = ref.current.getBounds();
const mapCenter = ref.current.getCenter();
onRegionChange(mapBounds, {
latitude: mapCenter.lat(),
longitude: mapCenter.lng(),
});
}

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.

onRegionChange changes its center argument shape at runtime — not behaviour-preserving

On main, getCenter() returned a raw google.maps.LatLng (read via .lat()/.lng()), passed straight to onRegionChange. This PR converts it to { latitude, longitude }, so consumers calling .lat()/.lng() will break. (The old Flow type claimed LatLong but never delivered it — this is arguably a fix, not a no-op.)

Please call it out in the PR description, re-check the minor label, and add a value assertion locking in the new shape (see #4757).

Nit: mapBounds is still the raw object but typed as Bounds — only center was normalised.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have adjusted the PR and created tests for this.

…r shape

Lock in the normalised { latitude, longitude } shape of the center argument
passed to onRegionChange so regressions are caught at the unit-test level.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@wpe1arhy Iris Li (wpe1arhy) 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.

LGTM

@wpe1arhy
Iris Li (wpe1arhy) merged commit 0ecfc59 into main Jul 22, 2026
15 checks passed
@wpe1arhy
Iris Li (wpe1arhy) deleted the ts-migration/bpk-component-map branch July 22, 2026 09:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

minor Non breaking change ts-conversion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bpk-component-map] Migrate to TypeScript

3 participants