Skip to content

fix: correct OfflineProgressStatus TypeScript type and TileRegionPackState typo#4223

Open
PHILLIPS71 wants to merge 3 commits into
rnmapbox:mainfrom
PHILLIPS71:fix/offline-progress-status-types
Open

fix: correct OfflineProgressStatus TypeScript type and TileRegionPackState typo#4223
PHILLIPS71 wants to merge 3 commits into
rnmapbox:mainfrom
PHILLIPS71:fix/offline-progress-status-types

Conversation

@PHILLIPS71
Copy link
Copy Markdown

@PHILLIPS71 PHILLIPS71 commented Jun 2, 2026

Description

Corrects the OfflineProgressStatus TypeScript type, which had several inaccuracies compared to what the native modules (Android/iOS) actually emit:

  • state was typed as number but is always a string, so it was changed to a strict union: 'invalid' | 'inactive' | 'active' | 'complete' | 'unknown'
  • Removed phantom fields completedTileCount and completedTileSize that were never emitted by native code
  • Added missing fields that native always emits: erroredResourceCount, loadedResourceSize, loadedResourceCount
  • Converted to a discriminated union on percentage to accurately model the two distinct payload shapes: one with full progress data and one emitted when a pack exists but has not yet started loading (percentage is null and resource counts are absent)
  • Narrowed OfflinePackDownloadState values in RNMBXModule.ts from string | number to string, consistent with what native actually sends
  • Fixed a typo in TileRegionPackState.UNKNOWN on Android: "unkown" to "unknown"

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

N/A type-only changes with one runtime string correction on Android.

Component to reproduce the issue you're fixing

// state was typed as number but native always emits a string
offlineManager.subscribe(pack, (pack, status) => {
  console.log(typeof status.state); // was typed as number, actually "active" | "complete" | etc.
  console.log(status.completedTileCount); // phantom field was always undefined at runtime
});

@PHILLIPS71 PHILLIPS71 requested a deployment to CI with Mapbox Tokens June 2, 2026 01:56 — with GitHub Actions Waiting
@PHILLIPS71 PHILLIPS71 requested a deployment to CI with Mapbox Tokens June 2, 2026 01:56 — with GitHub Actions Waiting
@PHILLIPS71 PHILLIPS71 requested a deployment to CI with Mapbox Tokens June 2, 2026 01:56 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant