mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
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:
parent
b5b61aec6a
commit
8a745f3f32
4 changed files with 19 additions and 8 deletions
13
commons/src/utils/deep-partial.ts
Normal file
13
commons/src/utils/deep-partial.ts
Normal 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
|
|
@ -5,3 +5,4 @@
|
|||
*/
|
||||
|
||||
export * from './wait-for-other-promises-to-finish.js'
|
||||
export type { DeepPartial } from './deep-partial.js'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue