Skip to content

[Due for payment 2026-05-11] [$250] Restore Type Safety for Onyx.update() #73830

Closed

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: @mallenexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 30, 2025
  2. changed the title [-]Restore Type Safety for Onyx.update()[/-] [+][$250] Restore Type Safety for Onyx.update()[/+] on Oct 30, 2025
  3. melvin-bot commented on Oct 30, 2025

    @melvin-bot
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 30, 2025
  5. melvin-bot commented on Oct 30, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (External)

  6. melvin-bot commented on Oct 30, 2025

    @melvin-bot

    Triggered auto assignment to @heyjennahay (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  7. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 30, 2025
  8. blazejkustra commented on Oct 30, 2025

    @blazejkustra
    ContributorAuthor

    @Ollyws I'll post a PR tomorrow morning as I couldn't get type tests to work properly

  9. 153 remaining items

  10. changed the title [-][$250] Restore Type Safety for Onyx.update()[/-] [+][Due for payment 2026-05-11] [$250] Restore Type Safety for Onyx.update()[/+] on May 4, 2026
  11. melvin-bot commented on May 4, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.65-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-05-11. 🎊

    For reference, here are some details about the assignees on this issue:

  12. melvin-bot commented on May 4, 2026

    @melvin-bot

    @Ollyws / @abzokhattab @mallenexpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  13. abzokhattab commented on May 4, 2026

    @abzokhattab
    Contributor

    Hi @OlGierd03 thanks for the great effort here .. do we expect more PRs on this topic?

  14. melvin-bot commented on May 4, 2026

    @melvin-bot

    @Ollyws Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. OlGierd03 commented on May 5, 2026

    @OlGierd03
    Contributor

    @abzokhattab that's all the PRs. Thanks for all the great reviews. The second batch, which removed @ts-expect-error was the last one. The issue is ready to be closed

  16. abzokhattab commented on May 5, 2026

    @abzokhattab
    Contributor

    Amazing!. Then summing it up for the payment:

    cc @mallenexpensify @mountiny

  17. moved this from HIGH to No status in [#whatsnext] #qualityon May 5, 2026
  18. moved this to AWAITING DEPLOYMENT in [#whatsnext] #qualityon May 5, 2026
  19. mallenexpensify commented on May 5, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @abzokhattab due $1250 via NewDot

    Thanks for the detailed, bulleted breakdown @abzokhattab , suuuuper helpful.

  20. moved this from AWAITING DEPLOYMENT to Done in [#whatsnext] #qualityon May 5, 2026
  21. quinthar commented on May 6, 2026

    @quinthar
    Contributor

    Approved $1250 to @abzokhattab

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions