-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: @heyjennahayMetadata
Metadata
Labels
Type
Projects
Status