fix: improve deep partial type used in tests

The deep partial type from redux had the problem that it could only be applied to records. This caused problems with primitive types and arrays.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-09-07 20:56:04 +02:00
parent b5b61aec6a
commit 8a745f3f32
4 changed files with 19 additions and 8 deletions

View file

@ -0,0 +1,13 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export type DeepPartial<T> = T extends null | undefined
? T
: T extends Array<infer ArrayType>
? Array<DeepPartial<ArrayType>>
: T extends Record<string | number | symbol, unknown>
? { [P in keyof T]?: DeepPartial<T[P]> }
: T

View file

@ -5,3 +5,4 @@
*/
export * from './wait-for-other-promises-to-finish.js'
export type { DeepPartial } from './deep-partial.js'