Skip to content

[Due for payment 2025-10-07] [$250] Enable safe usage of Array.prototype.toSorted across our app #71173

Description

@mountiny

Coming from this proposal

Background:

Our app already runs on Hermes, which is the default JavaScript engine for React Native on Android and is also used on iOS builds. While Array.prototype.toSorted is a modern ECMAScript method supported in V8 (Chrome) and JavaScriptCore (Safari), it is not yet available in Hermes. Developers want to safely use toSorted in the codebase. Without consistent cross-platform support, adopting this feature introduces risk of crashes and runtime errors in production.

Problem:

When Array.prototype.toSorted is called in Hermes, it throws an error because the method is not implemented, which prevents us from safely using it in our codebase.

Solution:

We will polyfill Array.prototype.toSorted to enable consistent usage across platforms. Implementation steps:

  1. Add the array.prototype.tosorted dependency to package.json.
  2. Import the package in src/setup/index.ts and invoke its shim() function to define the polyfill globally.
  3. Create a new file src/types/array.prototype.tosorted.d.ts to provide TypeScript type declarations for the functions exported by the package.
  4. Validate that the app runs without errors across all supported platforms.

This solution allows us to safely use toSorted across our app, ensuring modern JavaScript features can be used confidently in a cross-platform environment

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021970780473154053280
  • Upwork Job ID: 1970780473154053280
  • Last Price Increase: 2025-09-24
Issue OwnerCurrent Issue Owner: @clarajones-expensify

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions