Repository navigation
Premium Analytics: Use the Charts GeoDisplayMode type for the Locations map - #53016
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The type assertion bypasses the intended future compatibility check and should validate the scope object instead.
Review effort: Balanced
Findings: 1
What changed in this PR
Reuses Charts’ GeoDisplayMode type in Premium Analytics’ Locations map.
Changes:
- Re-export
GeoDisplayModethrough Premium Analytics externals. - Apply it to the Locations chart configuration.
- Add a type-only changelog entry.
| File | Description |
|---|---|
build-geo-data.ts |
Uses GeoDisplayMode for map configuration. |
externals/src/index.ts |
Re-exports the Charts type. |
changelog/update-pa-locations-geo-display-mode-type |
Records the internal type change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| region: focusCountry && ! useCountryFallbackMap ? focusCountry.code.toUpperCase() : 'world', | ||
| resolution: ( useProvinceMap ? 'provinces' : 'countries' ) as 'countries' | 'provinces', | ||
| displayMode: ( mode === 'city' ? 'markers' : 'regions' ) as 'regions' | 'markers', | ||
| displayMode: ( mode === 'city' ? 'markers' : 'regions' ) as GeoDisplayMode, |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Re-export the Charts GeoDisplayMode type through externals and use it in buildLocationsGeoChart in place of the inline 'regions' | 'markers' union.
A cast to GeoDisplayMode still compiles when Charts drops a display mode, because the literal union overlaps the narrower type. satisfies keeps the literals narrow and fails type checking instead.
e2f9662 to
c994fcf
Compare

Fixes N/A
Proposed changes
GeoDisplayModetype from Charts, but nothing used it:buildLocationsGeoChartwrote the same'regions' | 'markers'union out by hand in its config type and in its cast. This follows up on the review comment there.GeoDisplayModethrough the Premium Analytics externals and use it inbuildLocationsGeoChart, so the Locations map follows the Charts type if the display modes ever change. Theresolutionfield keeps its own'countries' | 'provinces'union, becauseGeoResolutionalso allows'metros'and the Locations map reads the narrower type.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions