From 9078da5279556f6dd9eafc4ed318835a5a9ecfac Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 9 Jul 2024 12:26:04 +0200 Subject: [PATCH] chore(templates): improve `DeepPartial` type --- src/runtime/types/utils.ts | 14 +++++++++++--- src/templates.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/runtime/types/utils.ts b/src/runtime/types/utils.ts index 9c31526d..4590b4de 100644 --- a/src/runtime/types/utils.ts +++ b/src/runtime/types/utils.ts @@ -1,6 +1,14 @@ -export type DeepPartial = Partial<{ - [P in keyof T]: DeepPartial | { [key: string]: string | object } -}> +export interface TightMap { + [key: string]: TightMap | O +} + +export type DeepPartial = { + [P in keyof T]?: T[P] extends object + ? DeepPartial + : T[P]; +} & { + [key: string]: O | TightMap +} export type DynamicSlots = Record & (Slot extends string ? Record : Record) diff --git a/src/templates.ts b/src/templates.ts index a7d5a7e3..92a73d06 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -101,7 +101,7 @@ type AppConfigUI = { gray?: 'slate' | 'cool' | 'zinc' | 'neutral' | 'stone' } icons?: Partial -} & DeepPartial +} & DeepPartial declare module 'nuxt/schema' { interface AppConfigInput {