Repository navigation
Description
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 Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Restore Type Safety for Onyx.update()[/-][+][$250] Restore Type Safety for Onyx.update()[/+]melvin-bot commentedon Oct 30, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021983883548495225073
melvin-bot commentedon Oct 30, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)melvin-bot commentedon Oct 30, 2025
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.blazejkustra commentedon Oct 30, 2025
@Ollyws I'll post a PR tomorrow morning as I couldn't get type tests to work properly
153 remaining items
[-][$250] Restore Type Safety for Onyx.update()[/-][+][Due for payment 2026-05-11] [$250] Restore Type Safety for Onyx.update()[/+]melvin-bot commentedon May 4, 2026
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:
@ts-expect-errorcomments related to OnyxUpdate changes - second batch #82786If no regressions arise, payment will be issued on 2026-05-11. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon May 4, 2026
@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]
abzokhattab commentedon May 4, 2026
Hi @OlGierd03 thanks for the great effort here .. do we expect more PRs on this topic?
melvin-bot commentedon May 4, 2026
@Ollyws Whoops! This issue is 2 days overdue. Let's get this updated quick!
OlGierd03 commentedon May 5, 2026
@abzokhattab that's all the PRs. Thanks for all the great reviews. The second batch, which removed
@ts-expect-errorwas the last one. The issue is ready to be closedabzokhattab commentedon May 5, 2026
Amazing!. Then summing it up for the payment:
@ts-expect-errorcomments related to OnyxUpdate changes - first batch #82255 and Resolve@ts-expect-errorcomments related to OnyxUpdate changes - second batch #82786 $250 each.cc @mallenexpensify @mountiny
mallenexpensify commentedon May 5, 2026
Payment Summary
Contributor+: @abzokhattab due $1250 via NewDot
Thanks for the detailed, bulleted breakdown @abzokhattab , suuuuper helpful.
quinthar commentedon May 6, 2026
Approved $1250 to @abzokhattab