chore(templates): improve DeepPartial type

This commit is contained in:
Benjamin Canac
2024-07-09 12:26:04 +02:00
parent c7536a7af9
commit 9078da5279
2 changed files with 12 additions and 4 deletions

View File

@@ -1,6 +1,14 @@
export type DeepPartial<T> = Partial<{
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object }
}>
export interface TightMap<O = any> {
[key: string]: TightMap | O
}
export type DeepPartial<T, O = any> = {
[P in keyof T]?: T[P] extends object
? DeepPartial<T[P], O>
: T[P];
} & {
[key: string]: O | TightMap<O>
}
export type DynamicSlots<T extends { slot?: string }, SlotProps, Slot = T['slot']> =
Record<string, SlotProps> & (Slot extends string ? Record<Slot, SlotProps> : Record<string, never>)

View File

@@ -101,7 +101,7 @@ type AppConfigUI = {
gray?: 'slate' | 'cool' | 'zinc' | 'neutral' | 'stone'
}
icons?: Partial<typeof icons>
} & DeepPartial<typeof ui>
} & DeepPartial<typeof ui, string>
declare module 'nuxt/schema' {
interface AppConfigInput {