Skip to content

Commit 56b9d1b

Browse files
committed
Use Partial instead of RecursivePartial for persisted state
The current state metadata takes an all-or-nothing approach to persisting each state property. There is no mechanism for omitting nested properties from the persisted state. As such, `Partial` is a better description of the return type than `RecursivePartial`.
1 parent 339818f commit 56b9d1b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/BaseControllerV2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ export function getAnonymizedState<S extends Record<string, any>>(
194194
export function getPersistentState<S extends Record<string, any>>(
195195
state: S,
196196
metadata: StateMetadata<S>,
197-
): RecursivePartial<S> {
197+
): Partial<S> {
198198
return Object.keys(state).reduce((persistedState, _key) => {
199199
const key: keyof S = _key; // https://stackoverflow.com/questions/63893394/string-cannot-be-used-to-index-type-t
200200
if (metadata[key].persist) {
201201
persistedState[key] = state[key];
202202
}
203203
return persistedState;
204-
}, {} as RecursivePartial<S>);
204+
}, {} as Partial<S>);
205205
}

0 commit comments

Comments
 (0)