Skip to content

[Due for payment 2026-01-28] [Due for payment 2026-01-23] [Due for payment 2026-01-20] [$250] Restore Type Safety for Onyx.update() #73830

@blazejkustra

Description

@blazejkustra

Background:

The frontend frequently reads and writes data to the backend using the Onyx data layer. Whenever a request is made, we optimistically set Onyx data via Onyx.update(). First updating the local cache, then syncing changes once the request succeeds/fails.

During the migration to TypeScript, @fabioh8010 and I ensured this function and accompanying types were type-safe, meaning only values defined in the Onyx schema could be set under a specific key. This safeguard protected against corrupted data, unexpected keys, and typos in key names, improving developer experience and data reliability.

Problem:

It's possible to set any value to any key when using Onyx.update():

    const optimisticData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: ONYXKEYS.IS_LOADING_REPORT_DATA, // boolean
            value: 'whatever value', // this doesn't raise a type error
        },
    ];

Solution:

Reintroduce the previous type definition in react-native-onyx (as it was implemented before PR #600) to restore schema-based type enforcement.

Then:
Update react-native-onyx in E/App.
Resolve around 120 resulting type errors in E/App

This change will restore strict type safety for Onyx.update(), preventing invalid data assignments at compile-time.

In React-native-onyx this will also be included:

  • add a comment above this magic type so that nobody touches it again
  • add type tests to Onyx
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021983883548495225073
  • Upwork Job ID: 1983883548495225073
  • Last Price Increase: 2025-10-30
  • Automatic offers:
    • abzokhattab | Contributor | 109423537
Issue OwnerCurrent Issue Owner: @heyjennahay

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

Status

HIGH

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions