react-native-onyx 1.0.83 → 1.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Onyx.d.ts CHANGED
@@ -1,15 +1,7 @@
1
1
  import {Component} from 'react';
2
2
  import {PartialDeep} from 'type-fest';
3
3
  import * as Logger from './Logger';
4
- import {
5
- CollectionKey,
6
- CollectionKeyBase,
7
- DeepRecord,
8
- KeyValueMapping,
9
- OnyxCollection,
10
- OnyxEntry,
11
- OnyxKey,
12
- } from './types';
4
+ import {CollectionKey, CollectionKeyBase, DeepRecord, KeyValueMapping, OnyxCollection, OnyxEntry, OnyxKey, NullableProperties} from './types';
13
5
 
14
6
  /**
15
7
  * Represents a mapping object where each `OnyxKey` maps to either a value of its corresponding type in `KeyValueMapping` or `null`.
@@ -210,7 +202,7 @@ declare function multiSet(data: Partial<NullableKeyValueMapping>): Promise<void>
210
202
  * @param key ONYXKEYS key
211
203
  * @param value Object or Array value to merge
212
204
  */
213
- declare function merge<TKey extends OnyxKey>(key: TKey, value: PartialDeep<KeyValueMapping[TKey]>): Promise<void>;
205
+ declare function merge<TKey extends OnyxKey>(key: TKey, value: NullableProperties<PartialDeep<KeyValueMapping[TKey]>>): Promise<void>;
214
206
 
215
207
  /**
216
208
  * Clear out all the data in the store
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {IsEqual, Merge} from 'type-fest';
1
+ import {Merge} from 'type-fest';
2
2
 
3
3
  /**
4
4
  * Represents a deeply nested record. It maps keys to values,
@@ -106,9 +106,7 @@ type OnyxKey = Key | CollectionKey;
106
106
  * The mapping is derived from the `values` property of the `TypeOptions` type.
107
107
  */
108
108
  type KeyValueMapping = {
109
- [TKey in keyof TypeOptions['values'] as TKey extends CollectionKeyBase
110
- ? `${TKey}${string}`
111
- : TKey]: TypeOptions['values'][TKey];
109
+ [TKey in keyof TypeOptions['values'] as TKey extends CollectionKeyBase ? `${TKey}${string}` : TKey]: TypeOptions['values'][TKey];
112
110
  };
113
111
 
114
112
  /**
@@ -182,6 +180,16 @@ type OnyxEntry<TOnyxValue> = TOnyxValue | null;
182
180
  */
183
181
  type OnyxCollection<TOnyxValue> = OnyxEntry<Record<string, TOnyxValue | null>>;
184
182
 
183
+ /**
184
+ * The `NullableProperties<T>` sets the values of all properties in `T` to be nullable (i.e., `| null`).
185
+ * It doesn't recurse into nested property values, this means it applies the nullability only to the top-level properties.
186
+ *
187
+ * @template T The type of the properties to convert to nullable properties.
188
+ */
189
+ type NullableProperties<T> = {
190
+ [P in keyof T]: T[P] | null;
191
+ };
192
+
185
193
  export {
186
194
  CollectionKey,
187
195
  CollectionKeyBase,
@@ -193,4 +201,5 @@ export {
193
201
  OnyxEntry,
194
202
  OnyxKey,
195
203
  Selector,
204
+ NullableProperties,
196
205
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.83",
3
+ "version": "1.0.86",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",